diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml index f7bc376..3e3b0ac 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/docker-build-push.yaml @@ -50,34 +50,8 @@ jobs: run: working-directory: services/ecran steps: - - uses: actions/checkout@v4 - - - name: Restore cache - uses: actions/cache/restore@v4 - id: cache - with: - path: | - services/ecran/node_modules - services/ecran/.next/cache - key: ${{ runner.os }}-bun-${{ hashFiles('services/ecran/package.json') }} - - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - - - name: Install dependencies - run: bun install - - - name: Build - run: bun run build - - - name: Save cache - uses: actions/cache/save@v4 - if: steps.cache.outputs.cache-hit != 'true' - with: - path: | - services/ecran/node_modules - services/ecran/.next/cache - key: ${{ runner.os }}-bun-${{ hashFiles('services/ecran/package.json') }} + - name: Checkout + uses: actions/checkout@v4 - name: Login to Container Registry uses: docker/login-action@v3 diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 87256bf..9a85dac 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -11,40 +11,41 @@ concurrency: cancel-in-progress: true jobs: - build: + build-ecran: runs-on: arc-arm64 defaults: run: working-directory: services/ecran steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - name: Restore cache - uses: actions/cache/restore@v4 - id: cache + - name: Login to Container Registry + uses: docker/login-action@v3 with: - path: | - services/ecran/node_modules - services/ecran/.next/cache - key: ${{ runner.os }}-bun-${{ hashFiles('services/ecran/package.json') }} - - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - - - name: Install dependencies - run: bun install - - - name: Build - run: bun run build + registry: kalmyk.duckdns.org + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} - - name: Save cache - uses: actions/cache/save@v4 - if: steps.cache.outputs.cache-hit != 'true' + - name: Build and push ecran + uses: docker/build-push-action@v6 with: - path: | - services/ecran/node_modules - services/ecran/.next/cache - key: ${{ runner.os }}-bun-${{ hashFiles('services/ecran/package.json') }} + push: true + context: services/ecran + file: services/ecran/Dockerfile + platforms: linux/arm64 + tags: kalmyk.duckdns.org/lab/ecran:latest + cache-from: type=registry,ref=kalmyk.duckdns.org/lab/ecran:latest + cache-to: type=inline + + build-worker: + runs-on: arc-arm64 + defaults: + run: + working-directory: services/ecran + steps: + - name: Checkout + uses: actions/checkout@v4 - name: Login to Container Registry uses: docker/login-action@v3 @@ -53,13 +54,13 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_TOKEN }} - - name: Package into Docker image + - name: Build and push worker uses: docker/build-push-action@v6 with: push: true context: services/ecran - file: services/ecran/Dockerfile.package + file: services/ecran/Dockerfile.worker platforms: linux/arm64 - tags: kalmyk.duckdns.org/lab/ecran:latest - cache-from: type=registry,ref=kalmyk.duckdns.org/lab/ecran:latest + tags: kalmyk.duckdns.org/lab/ecran-worker:latest + cache-from: type=registry,ref=kalmyk.duckdns.org/lab/ecran-worker:latest cache-to: type=inline diff --git a/bun.lockb b/bun.lockb deleted file mode 100755 index 8a0c77f..0000000 Binary files a/bun.lockb and /dev/null differ diff --git a/services/ecran/Dockerfile b/services/ecran/Dockerfile index 2ae2f01..ae08648 100644 --- a/services/ecran/Dockerfile +++ b/services/ecran/Dockerfile @@ -1,34 +1,32 @@ -FROM oven/bun:1 as base -FROM base AS deps +FROM oven/bun:latest AS deps WORKDIR /app -COPY package.json ./ -COPY .npmrc ./ +COPY package.json bun.lockb .npmrc ./ +RUN bun install --frozen-lockfile -RUN bun install - -# Rebuild the source code only when needed -FROM base AS builder +FROM node:lts-alpine AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -ENV NEXT_TELEMETRY_DISABLED=1 -RUN pnpm run build +RUN npm run build -# Production image, copy all the files and run next FROM node:lts-alpine AS runner WORKDIR /app + ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs -COPY --from=builder /app/public ./public -COPY --from=builder /app/.next/standalone ./ -COPY --from=builder /app/.next/static ./.next/static - -# Set the correct permission for prerender cache -RUN chown -R nextjs:nodejs .next + +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs + +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +COPY --from=builder --chown=nextjs:nodejs /app/public ./public + USER nextjs + EXPOSE 3000 + ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" CMD ["node", "server.js"] diff --git a/services/ecran/Dockerfile.package b/services/ecran/Dockerfile.package deleted file mode 100644 index 054c080..0000000 --- a/services/ecran/Dockerfile.package +++ /dev/null @@ -1,22 +0,0 @@ -FROM node:lts-alpine -WORKDIR /app - -ENV NODE_ENV=production -ENV NEXT_TELEMETRY_DISABLED=1 - -RUN addgroup --system --gid 1001 nodejs && \ - adduser --system --uid 1001 nextjs - -# Copy the pre-built application -COPY .next/standalone ./ -COPY .next/static ./.next/static -COPY public ./public - -USER nextjs - -EXPOSE 3000 - -ENV PORT=3000 -ENV HOSTNAME="0.0.0.0" - -CMD ["node", "server.js"] diff --git a/services/ecran/Dockerfile.worker b/services/ecran/Dockerfile.worker index f9fedcf..aefbc9c 100644 --- a/services/ecran/Dockerfile.worker +++ b/services/ecran/Dockerfile.worker @@ -1,21 +1,18 @@ -FROM node:lts-slim AS deps +FROM oven/bun:latest AS deps WORKDIR /app -RUN npm install -g pnpm -COPY package.json ./ -COPY .npmrc ./ -RUN pnpm install +COPY package.json bun.lockb .npmrc ./ +RUN bun install FROM node:lts-slim AS builder WORKDIR /app -RUN npm install -g pnpm COPY --from=deps /app/node_modules ./node_modules COPY . . -RUN pnpm run build:workflow +RUN npm run build:workflow -FROM node:lts-slim +FROM node:lts-slim AS runner WORKDIR /app -RUN npm install -g pnpm && pnpm install esbuild-loader +RUN npm install esbuild-loader COPY --from=builder /app . -CMD ["pnpm", "run", "start:worker"] +CMD ["npm", "run", "start:worker"] diff --git a/services/ecran/bun.lockb b/services/ecran/bun.lockb index 9f8ac6b..e4e735d 100755 Binary files a/services/ecran/bun.lockb and b/services/ecran/bun.lockb differ diff --git a/services/ecran/package.json b/services/ecran/package.json index 586b3ca..3421803 100644 --- a/services/ecran/package.json +++ b/services/ecran/package.json @@ -67,12 +67,12 @@ "drizzle-orm": "0.36.4", "esbuild": "0.24.0", "esbuild-loader": "4.2.2", + "framer-motion": "12.0.0-alpha.2", "highlight.js": "11.10.0", "immer": "10.1.1", "logrocket": "9.0.0", "lucide-react": "0.462.0", "monaco-editor": "0.52.0", - "framer-motion": "12.0.0-alpha.2", "next": "15.0.3", "next-auth": "5.0.0-beta.25", "next-mdx-remote": "5.0.0",