Get rid of cache during frontend build and remove development env from frontend Dockerfile
All checks were successful
Podman Rootless Demo / test-backend (push) Has been skipped
Podman Rootless Demo / test-frontend (push) Successful in 11s
Podman Rootless Demo / build-backend (push) Has been skipped
Podman Rootless Demo / build-frontend (push) Successful in 2m21s
Podman Rootless Demo / deploy-prod (push) Successful in 48s

This commit is contained in:
continuist 2025-09-21 01:49:16 -04:00
parent 6d0a3ceb18
commit 77c371c702
2 changed files with 23 additions and 30 deletions

View file

@ -199,7 +199,7 @@ jobs:
- name: Build frontend container image - name: Build frontend container image
run: | run: |
podman --remote build \ podman --remote build --no-cache \
-f frontend/Dockerfile \ -f frontend/Dockerfile \
-t "$FRONTEND_IMAGE:${{ github.sha }}" \ -t "$FRONTEND_IMAGE:${{ github.sha }}" \
-t "$FRONTEND_IMAGE:latest" \ -t "$FRONTEND_IMAGE:latest" \

View file

@ -1,53 +1,46 @@
# Multi-stage build for Next.js frontend # ---------- build ----------
FROM docker.io/node:20-alpine AS builder FROM docker.io/node:20-alpine AS builder
# Set working directory
WORKDIR /app WORKDIR /app
ENV NODE_ENV=development # install deps (needs dev deps for build)
# Copy package files
COPY package*.json ./ COPY package*.json ./
# Install all dependencies (including dev dependencies for build)
RUN npm ci RUN npm ci
# Copy source code # app source
COPY . . COPY . .
# disable telemetry; let Next control NODE_ENV during build
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
# Build the application
RUN npm run build RUN npm run build
# Production stage # ---------- runner (standalone) ----------
FROM docker.io/node:20-alpine AS runner FROM docker.io/node:20-alpine AS runner
# Create non-root user
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
WORKDIR /app WORKDIR /app
# Copy standalone artifacts # runtime env
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# Ownership
RUN chown -R nextjs:nodejs /app
USER nextjs
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000 ENV PORT=3000
ENV HOSTNAME=127.0.0.1 ENV HOSTNAME=127.0.0.1
# minimal probe tool
RUN apk add --no-cache wget
# copy standalone artifacts
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# non-root (optional)
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs \
&& chown -R nextjs:nodejs /app
USER nextjs
EXPOSE 3000 EXPOSE 3000
# Healthcheck: hit the frontend root over IPv4 (no curl needed) # healthcheck (no /api prefix)
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://127.0.0.1:${PORT}/ >/dev/null 2>&1 || exit 1 CMD wget -qO- http://127.0.0.1:${PORT}/ >/dev/null 2>&1 || exit 1
# Run the application CMD ["node", "server.js"]
CMD ["node", "server.js"]