attempt 2
Some checks failed
Deploy Frontend / deploy (push) Failing after 25s

This commit is contained in:
Lee 2024-10-03 19:45:30 +01:00
parent 05beac41dd
commit 861578cc90
2 changed files with 28 additions and 48 deletions

@ -25,7 +25,8 @@ jobs:
- name: Build Image - name: Build Image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: ./apps/frontend context: .
file: ./apps/frontend/Dockerfile
push: true push: true
tags: | tags: |
git.fascinated.cc/fascinated/scoresaber-reloaded-frontend:${{ github.sha }} git.fascinated.cc/fascinated/scoresaber-reloaded-frontend:${{ github.sha }}

@ -1,65 +1,44 @@
FROM fascinated/docker-images:nodejs_20_with_pnpm AS base FROM fascinated/docker-images:nodejs_20_with_pnpm AS base
# Install dependencies and build tools for canvas
FROM base AS deps
RUN apk add --no-cache python3 make g++ gcc pkgconfig pixman cairo-dev libjpeg-turbo-dev pango-dev giflib-dev
WORKDIR /app
COPY package.json* pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile --quiet
# Build from source
FROM base AS builder FROM base AS builder
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
RUN pnpm global add turbo@^2
COPY . . COPY . .
# Install runtime dependencies # Generate a partial monorepo with a pruned lockfile for a target workspace.
RUN apk add --no-cache cairo pango libjpeg-turbo giflib # Assuming "frontend" is the name entered in the project's package.json: { name: "frontend" }
RUN turbo prune frontend --docker
ENV NEXT_TELEMETRY_DISABLED=1 # Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Add the commit hash # First install the dependencies (as they change less often)
ARG GIT_REV COPY --from=builder /app/out/json/ .
ENV GIT_REV=${GIT_REV} RUN pnpm install --frozen-lockfile --quiet
# Add the sentry auth token # Build the project
ARG SENTRY_AUTH_TOKEN COPY --from=builder /app/out/full/ .
ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} RUN pnpm turbo run build --filter=frontend...
# Build the app
RUN pnpm run build
# Final stage to run the app
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
# Install runtime dependencies # Don't run production as root
RUN apk add --no-cache cairo pango libjpeg-turbo giflib
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
RUN mkdir .next
RUN chown nextjs:nodejs .next
# Add the commit hash
ARG GIT_REV
ENV GIT_REV=${GIT_REV}
# Copy the built app from the builder stage
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/next.config.mjs ./next.config.mjs
USER nextjs USER nextjs
EXPOSE 3000 # Automatically leverage output traces to reduce image size
ENV HOSTNAME="0.0.0.0" # https://nextjs.org/docs/advanced-features/output-file-tracing
ENV PORT=3000 COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/.next/static ./apps/frontend/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/public ./apps/frontend/public
CMD ["pnpm", "start"] CMD node apps/frontend/server.js