From 18a45e0eebe347ab6d1c7494c02258764d41a340 Mon Sep 17 00:00:00 2001 From: Matteo Sillitti <65899974+Matt0550@users.noreply.github.com> Date: Sat, 3 May 2025 12:21:41 +0200 Subject: [PATCH 1/2] [+] Added docker support --- Dockerfile | 66 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 9 +++++++ 2 files changed, 75 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..72b8c3fe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,66 @@ +# syntax=docker.io/docker/dockerfile:1 + +FROM node:22-alpine AS base + +# Install dependencies only when needed +FROM base AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +WORKDIR /app + +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry during the build. +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN \ + if [ -f yarn.lock ]; then yarn run build; \ + elif [ -f package-lock.json ]; then npm run build; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ + else echo "Lockfile not found." && exit 1; \ + fi + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production +# Uncomment the following line in case you want to disable telemetry during runtime. +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 + +# server.js is created by next build from the standalone output +# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output +ENV HOSTNAME="0.0.0.0" +CMD ["node", "server.js"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..46aa7750 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + nextjs: + build: + context: . + dockerfile: Dockerfile + ports: + - "3000:3000" + env_file: + - .env \ No newline at end of file From 4fad4ed5909d7e881135b69f6ec7f8c704cc638e Mon Sep 17 00:00:00 2001 From: Matt0550 <65899974+Matt0550@users.noreply.github.com> Date: Wed, 25 Jun 2025 13:35:16 +0200 Subject: [PATCH 2/2] ci/cd docker build demo livekit server --- .github/workflows/docker.build.yaml | 35 ++++++++++++++++++++++++++++ docker-compose.yml | 36 ++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker.build.yaml diff --git a/.github/workflows/docker.build.yaml b/.github/workflows/docker.build.yaml new file mode 100644 index 00000000..e73e4cc5 --- /dev/null +++ b/.github/workflows/docker.build.yaml @@ -0,0 +1,35 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}/meet-app + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 46aa7750..5816fb67 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,4 +6,38 @@ services: ports: - "3000:3000" env_file: - - .env \ No newline at end of file + - .env + depends_on: + - livekit + + livekit: + image: livekit/livekit-server:latest + ports: + - "7880:7880" # HTTP + - "7881:7881" # HTTPS/WSS + - "7882:7882/udp" # WebRTC UDP + environment: + - LIVEKIT_CONFIG_FILE=/config/config.yaml + env_file: + - .env + volumes: + - ./livekit:/config + command: ["--config", "/config/config.yaml"] + +# EXAMPLE CONFIG yaml for LiveKit +# Save this as livekit/config.yaml +# port: 7880 +# bind_addresses: +# - "" +# api: +# key: your_actual_api_key +# secret: your_actual_api_secret +# rtc: +# tcp_port: 7881 +# port_range_start: 50000 +# port_range_end: 60000 +# turn: +# enabled: true +# domain: localhost +# tls_port: 5349 +# udp_port: 3478 \ No newline at end of file