diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 5ba8f14..b972cf6 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -5,6 +5,11 @@ on: types: [opened, synchronize] paths: - "services/**" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build: runs-on: arc-arm64 @@ -15,26 +20,37 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Cache Next.js build - uses: actions/cache@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 with: - path: | - services/ecran/.next/cache - key: ${{ runner.os }}-next-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-next- - - - name: Set up pnpm - uses: pnpm/action-setup@v4 + image: public.ecr.aws/eks-distro-build-tooling/binfmt-misc:qemu-v7.0.0 - - name: Install Node.js - uses: actions/setup-node@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 with: - node-version: 22 - cache: pnpm + driver-opts: | + image=moby/buildkit:v0.18.0 - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Login to Container Registry + uses: docker/login-action@v3 + with: + registry: kalmyk.duckdns.org + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} - - name: Build - run: pnpm run build + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: services/ecran + file: services/ecran/Dockerfile.package + platforms: linux/arm64 + push: true + tags: kalmyk.duckdns.org/lab/ecran:${{ github.sha }},kalmyk.duckdns.org/lab/ecran:latest + target: runner + build-args: | + NEXT_PUBLIC_COMMIT_SHA=${{ github.sha }} + cache-from: type=registry,ref=kalmyk.duckdns.org/lab/ecran:latest + cache-to: type=inline + secrets: | + github-token=${{ secrets.GITHUB_TOKEN }} + provenance: false diff --git a/services/ecran/Dockerfile.package b/services/ecran/Dockerfile.package new file mode 100644 index 0000000..aa14f28 --- /dev/null +++ b/services/ecran/Dockerfile.package @@ -0,0 +1,48 @@ +FROM node:lts-alpine AS builder +WORKDIR /app + +# Install pnpm +RUN --mount=type=cache,target=/root/.npm \ + npm install -g pnpm + +# Copy package files +COPY package.json pnpm-lock.yaml ./ +COPY .npmrc ./ + +# Install dependencies with cache +RUN --mount=type=cache,target=/root/.local/share/pnpm/store,id=pnpm-store \ + --mount=type=cache,target=/app/node_modules,id=node-modules \ + pnpm install --no-frozen-lockfile + +# Copy source files +COPY . . + +# Build the application with cache +RUN --mount=type=cache,target=/app/.next/cache,id=next-cache \ + --mount=type=cache,target=/app/node_modules,id=node-modules \ + --mount=type=cache,target=/root/.local/share/pnpm/store,id=pnpm-store \ + NEXT_TELEMETRY_DISABLED=1 pnpm run build + +# Production image +FROM node:lts-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs + +# Copy build output from builder +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/src/app/problems/page.tsx b/services/ecran/src/app/problems/page.tsx index 2014824..cb4b8df 100644 --- a/services/ecran/src/app/problems/page.tsx +++ b/services/ecran/src/app/problems/page.tsx @@ -80,13 +80,26 @@ export default async function ProblemsPage(props: ProblemsPageProps) {
-
Problems
+
+ + {total} + +

Problems

+
-
+
+ Loading problems... +
} >