FROM node:18-slim # Install ffmpeg, ca-certificates, and other useful tools for SSL support RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg curl ca-certificates wget unzip file && \ apt-get clean && rm -rf /var/lib/apt/lists/* # --- Add Rhubarb Installation Here --- # Switch to root to install Rhubarb, then switch back to node user later if needed before app execution USER root ARG RHUBARB_VERSION=1.13.0 RUN \ echo "Downloading Rhubarb version ${RHUBARB_VERSION}" && \ wget https://github.com/DanielSWolf/rhubarb-lip-sync/releases/download/v${RHUBARB_VERSION}/rhubarb-lip-sync-${RHUBARB_VERSION}-linux.zip -O /tmp/rhubarb.zip && \ echo "--- Listing /tmp to check zip file: ---" && \ ls -l /tmp/rhubarb.zip && \ echo "--- File type of /tmp/rhubarb.zip: ---" && \ file /tmp/rhubarb.zip && \ echo "--- Creating temporary extraction directory /tmp/rhubarb_extracted ---" && \ mkdir -p /tmp/rhubarb_extracted && \ echo "--- Unzipping to /tmp/rhubarb_extracted ---" && \ unzip /tmp/rhubarb.zip -d /tmp/rhubarb_extracted && \ echo "--- Listing /tmp/rhubarb_extracted (recursive): ---" && \ ls -R /tmp/rhubarb_extracted && \ echo "--- Finding rhubarb executable in /tmp/rhubarb_extracted ---" && \ RHUBARB_EXEC_PATH=$(find /tmp/rhubarb_extracted -name rhubarb -type f -executable -print -quit) && \ if [ -z "${RHUBARB_EXEC_PATH}" ]; then \ echo "ERROR: Could not find rhubarb executable in /tmp/rhubarb_extracted"; \ ls -R /tmp/rhubarb_extracted; \ exit 1; \ fi && \ echo "Found rhubarb executable at: ${RHUBARB_EXEC_PATH}" && \ echo "--- Moving ${RHUBARB_EXEC_PATH} to /usr/local/bin/rhubarb ---" && \ mv "${RHUBARB_EXEC_PATH}" "/usr/local/bin/rhubarb" && \ chmod +x "/usr/local/bin/rhubarb" && \ echo "--- Cleaning up /tmp/rhubarb.zip and /tmp/rhubarb_extracted ---" && \ rm -rf "/tmp/rhubarb.zip" "/tmp/rhubarb_extracted" USER node # Diagnostic commands for the node user RUN echo "Running diagnostics as $(whoami)" RUN echo "PATH is: $PATH" RUN which rhubarb || echo "rhubarb not found in PATH for node user during build" # Set environment variables ENV NODE_ENV=production ENV PORT=7860 # Create app directory and set it as working directory WORKDIR /home/node/app # Copy package.json and package-lock.json (or yarn.lock) first # This allows Docker to cache the npm install step if these files don't change COPY --chown=node:node backend/package.json backend/package-lock.json* ./ # If you use yarn, uncomment the next line and comment out the npm ci line # COPY --chown=node:node backend/package.json backend/yarn.lock ./ # Install dependencies # Using npm ci for cleaner installs if package-lock.json is present RUN npm ci --only=production # If you use yarn, uncomment the next line and comment out the npm ci line # RUN yarn install --production --frozen-lockfile # Copy the rest of the application files from the backend directory COPY --chown=node:node backend/ ./ # Create audios and public directories explicitly to avoid ENOENT errors RUN mkdir -p /home/node/app/audios /home/node/app/public # Optionally, create a placeholder index.html if no static files are copied # This prevents ENOENT errors when serving index.html RUN echo '
This is a placeholder page. Update with actual content if needed.
' > /home/node/app/public/index.html # Download or install rhubarb binary at build time or runtime # Replace the URL below with the actual source for rhubarb if available # RUN mkdir -p /home/node/app/backend/bin && \ # curl -L -o /home/node/app/backend/bin/rhubarb 'https://example.com/path/to/rhubarb-binary' && \ # chmod +x /home/node/app/backend/bin/rhubarb # Note: The above command is commented out as the URL is a placeholder. Please provide the correct URL or method to obtain rhubarb. # Alternatively, consider using a script at startup to download it if it cannot be done at build time. # Expose the port the app runs on EXPOSE 7860 # Command to run the application CMD [ "node", "index.js" ]