captap / Dockerfile
Yakova's picture
Update Dockerfile
a945e94 verified
raw
history blame
5.27 kB
FROM ubuntu:22.04
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV WINEDEBUG=-all
ENV DISPLAY=:99
ENV WINEARCH=win64
ENV WINEPREFIX=/root/.wine
# Fix for XDG_RUNTIME_DIR error
ENV XDG_RUNTIME_DIR=/tmp/runtime-root
# Install dependencies (minimal headless setup)
RUN apt-get update && apt-get install -y \
software-properties-common \
apt-transport-https \
wget \
gnupg2 \
xvfb \
sudo \
cabextract \
xz-utils \
p7zip-full \
curl \
unzip \
&& dpkg --add-architecture i386 \
&& apt-get update
# Add Wine repository
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key \
&& apt-key add winehq.key \
&& add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ jammy main' \
&& apt-get update
# Install Wine and winetricks
RUN apt-get install -y --install-recommends winehq-devel winetricks
# Create XDG_RUNTIME_DIR to avoid errors
RUN mkdir -p /tmp/runtime-root && chmod 700 /tmp/runtime-root
# Initialize wine
RUN Xvfb :99 -screen 0 1024x768x16 & \
sleep 2 && \
DISPLAY=:99 wine wineboot --init && \
wineserver -w
# Configure Wine settings
RUN Xvfb :99 -screen 0 1024x768x16 & \
sleep 2 && \
DISPLAY=:99 winecfg -v win11 && \
# Disable window manager decorations and control
echo '[Software\\\\Wine\\\\X11 Driver]' > /tmp/graphics.reg && \
echo '"Decorated"="N"' >> /tmp/graphics.reg && \
echo '"Managed"="N"' >> /tmp/graphics.reg && \
DISPLAY=:99 wine regedit /tmp/graphics.reg && \
rm /tmp/graphics.reg && \
wineserver -w
# Install Windows components using winetricks
RUN Xvfb :99 -screen 0 1024x768x16 & \
sleep 2 && \
DISPLAY=:99 winetricks -q vcrun2019 && \
DISPLAY=:99 winetricks -q corefonts && \
wineserver -w
# Create directory for CapCut files
RUN mkdir -p /opt/capcut
# Download and install CapCut
RUN mkdir -p /tmp/capcut-download \
&& cd /tmp/capcut-download \
&& wget -O capcut_setup.exe "https://lf16-capcut.faceulv.com/obj/capcutpc-packages-us/packages/CapCut_setup_9.9.0_capcutpc_0_us.exe" \
&& echo "Extracting CapCut installer..." \
&& Xvfb :99 -screen 0 1024x768x16 & \
sleep 2 && \
DISPLAY=:99 wine capcut_setup.exe /S /D=C:\\CapCut \
&& sleep 30 \
&& wineserver -w \
&& cp -r "$WINEPREFIX/drive_c/CapCut/"* /opt/capcut/ 2>/dev/null || true \
&& rm -rf /tmp/capcut-download
# Create a headless command script for CapCut operations
RUN echo '#!/bin/bash \n\
# Function to run a CapCut command with proper setup \n\
run_capcut_command() { \n\
# Create runtime directory \n\
mkdir -p $XDG_RUNTIME_DIR \n\
chmod 700 $XDG_RUNTIME_DIR \n\
\n\
# Start virtual display in background \n\
Xvfb :99 -screen 0 1920x1080x24 & \n\
XVFB_PID=$! \n\
sleep 2 \n\
\n\
# Set aspect ratio to fix black preview issue \n\
echo "[HKEY_CURRENT_USER\\\\Software\\\\ByteDance\\\\CapCut]" > /tmp/capcut_settings.reg \n\
echo "\"AspectRatio\"=\"16:9\"" >> /tmp/capcut_settings.reg \n\
DISPLAY=:99 wine regedit /tmp/capcut_settings.reg \n\
rm /tmp/capcut_settings.reg \n\
\n\
# Run the command \n\
cd /opt/capcut \n\
DISPLAY=:99 wine capcut.exe $@ \n\
\n\
# Clean up \n\
kill $XVFB_PID \n\
} \n\
\n\
# Process input and project files if mounted \n\
if [ -d "/input" ]; then \n\
cp -r /input/* /opt/capcut/projects/ 2>/dev/null || true \n\
fi \n\
\n\
# Handle command line arguments \n\
case "$1" in \n\
"process") \n\
# Example: Process a project file \n\
if [ -n "$2" ]; then \n\
PROJECT_FILE="$2" \n\
OUTPUT_PATH="${3:-/output}" \n\
echo "Processing project: $PROJECT_FILE" \n\
run_capcut_command --headless --process "$PROJECT_FILE" --output "$OUTPUT_PATH" \n\
else \n\
echo "Error: No project file specified" \n\
exit 1 \n\
fi \n\
;; \n\
"export") \n\
# Example: Export a project \n\
if [ -n "$2" ]; then \n\
PROJECT_FILE="$2" \n\
OUTPUT_PATH="${3:-/output}" \n\
echo "Exporting project: $PROJECT_FILE" \n\
run_capcut_command --headless --export "$PROJECT_FILE" --output "$OUTPUT_PATH" \n\
else \n\
echo "Error: No project file specified" \n\
exit 1 \n\
fi \n\
;; \n\
"render") \n\
# Example: Render a project \n\
if [ -n "$2" ]; then \n\
PROJECT_FILE="$2" \n\
OUTPUT_PATH="${3:-/output}" \n\
echo "Rendering project: $PROJECT_FILE" \n\
run_capcut_command --headless --render "$PROJECT_FILE" --output "$OUTPUT_PATH" \n\
else \n\
echo "Error: No project file specified" \n\
exit 1 \n\
fi \n\
;; \n\
"custom") \n\
# Run custom CapCut command \n\
shift \n\
echo "Running custom command: $@" \n\
run_capcut_command $@ \n\
;; \n\
*) \n\
# Default: Just run CapCut with provided arguments \n\
echo "Running CapCut with arguments: $@" \n\
run_capcut_command $@ \n\
;; \n\
esac \n\
' > /usr/local/bin/capcut-cli
RUN chmod +x /usr/local/bin/capcut-cli
# Create output directory
RUN mkdir -p /output
# Create directories for projects
RUN mkdir -p /opt/capcut/projects
# Set the entrypoint to our headless command script
ENTRYPOINT ["/usr/local/bin/capcut-cli"]
# Default command (can be overridden)
CMD ["--help"]