diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9f5584e..35df6f9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -37,12 +37,16 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=ref,event=branch + type=sha # 3. Build and push Docker image - name: Build and push Docker image uses: docker/build-push-action@v5 with: - context: . + context: ./backend push: ${{ github.event_name != 'pull_request' }} # Only push on merge to main tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -73,5 +77,5 @@ jobs: script: | cd ~/my-app echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - docker compose pull - docker compose up -d + docker-compose pull + docker-compose up -d \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile index e39ce77..f2b3022 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,3 +1,4 @@ +docker # --- STAGE 1: Build --- FROM node:20-alpine AS builder WORKDIR /app @@ -19,11 +20,12 @@ ENV NODE_ENV=production # Copy ONLY the production dependencies (ignores devDependencies like TypeScript) COPY package*.json ./ -RUN npm install --omit=dev +RUN apk add --no-cache ffmpeg ca-certificates && \ + npm install --omit=dev # Copy the compiled JS from the builder stage COPY --from=builder /app/dist ./dist # Start the app EXPOSE 3000 -CMD ["node", "dist/index.js"] \ No newline at end of file +CMD ["node", "dist/utils/index.js"] \ No newline at end of file diff --git a/backend/src/services/transcription.service.ts b/backend/src/services/transcription.service.ts index d218219..845b254 100644 --- a/backend/src/services/transcription.service.ts +++ b/backend/src/services/transcription.service.ts @@ -15,10 +15,13 @@ const TEMP_DIR = path.resolve(ROOT_DIR, 'temp_audio'); const SOURCE_AUDIO = path.resolve(TEMP_DIR, 'source_audio.mp3'); // Configure FFmpeg paths -if (ffmpegStatic) { +if (process.env.NODE_ENV === 'production') { + // In production (Docker), we prefer the system-installed ffmpeg + console.log("Using system ffmpeg in production"); +} else if (ffmpegStatic) { ffmpeg.setFfmpegPath(ffmpegStatic); } else { - throw new Error("FFmpeg binary path could not be resolved."); + console.warn("ffmpeg-static path could not be resolved, falling back to system ffmpeg."); } if (ffprobeStatic && ffprobeStatic.path) { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d33261d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + web: + image: ghcr.io/edwardrl101/ai-lecture-video-helper:latest + ports: + - "80:3000" + pull_policy: always + env_file: + - .env