fix: implement Lean Docker strategy with mintel/runtime and remove explicit container_name fields
This commit is contained in:
@@ -97,7 +97,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Nextjs Base
|
- name: 🏗️ Build & Push Nextjs Build-Base
|
||||||
env:
|
env:
|
||||||
TAG: ${{ github.ref_name }}
|
TAG: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
@@ -108,6 +108,17 @@ jobs:
|
|||||||
-f packages/infra/docker/Dockerfile.nextjs \
|
-f packages/infra/docker/Dockerfile.nextjs \
|
||||||
--push .
|
--push .
|
||||||
|
|
||||||
|
- name: 🏗️ Build & Push Production Runtime
|
||||||
|
env:
|
||||||
|
TAG: ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
-t registry.infra.mintel.me/mintel/runtime:$TAG \
|
||||||
|
-t registry.infra.mintel.me/mintel/runtime:latest \
|
||||||
|
-f packages/infra/docker/Dockerfile.runtime \
|
||||||
|
--push .
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Gatekeeper (Product)
|
- name: 🏗️ Build & Push Gatekeeper (Product)
|
||||||
env:
|
env:
|
||||||
TAG: ${{ github.ref_name }}
|
TAG: ${{ github.ref_name }}
|
||||||
|
|||||||
@@ -20,23 +20,13 @@ ENV DIRECTUS_URL=$DIRECTUS_URL
|
|||||||
RUN pnpm --filter sample-website build
|
RUN pnpm --filter sample-website build
|
||||||
|
|
||||||
# Production runner image
|
# Production runner image
|
||||||
FROM node:20-alpine AS runner
|
FROM registry.infra.mintel.me/mintel/runtime:latest AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install curl for health checks
|
|
||||||
RUN apk add --no-cache curl
|
|
||||||
|
|
||||||
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/apps/sample-website/public ./apps/sample-website/public
|
COPY --from=builder /app/apps/sample-website/public ./apps/sample-website/public
|
||||||
|
|
||||||
# Set the correct permission for prerender cache
|
# Set the correct permission for prerender cache
|
||||||
RUN mkdir -p apps/sample-website/.next
|
RUN mkdir -p apps/sample-website/.next && chown nextjs:nodejs apps/sample-website/.next
|
||||||
RUN chown nextjs:nodejs apps/sample-website/.next
|
|
||||||
|
|
||||||
# Copy standalone output and static files from the monorepo path
|
# Copy standalone output and static files from the monorepo path
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/sample-website/.next/standalone ./
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/sample-website/.next/standalone ./
|
||||||
@@ -44,10 +34,5 @@ COPY --from=builder --chown=nextjs:nodejs /app/apps/sample-website/.next/static
|
|||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
ENV PORT=3000
|
|
||||||
ENV HOSTNAME="0.0.0.0"
|
|
||||||
|
|
||||||
# server.js in monorepo standalone is created for each app
|
# server.js in monorepo standalone is created for each app
|
||||||
CMD ["node", "apps/sample-website/server.js"]
|
CMD ["node", "apps/sample-website/server.js"]
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ services:
|
|||||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID: ${NEXT_PUBLIC_UMAMI_WEBSITE_ID}
|
NEXT_PUBLIC_UMAMI_WEBSITE_ID: ${NEXT_PUBLIC_UMAMI_WEBSITE_ID}
|
||||||
NEXT_PUBLIC_UMAMI_SCRIPT_URL: ${NEXT_PUBLIC_UMAMI_SCRIPT_URL}
|
NEXT_PUBLIC_UMAMI_SCRIPT_URL: ${NEXT_PUBLIC_UMAMI_SCRIPT_URL}
|
||||||
NEXT_PUBLIC_TARGET: ${TARGET:-development}
|
NEXT_PUBLIC_TARGET: ${TARGET:-development}
|
||||||
DIRECTUS_URL: ${DIRECTUS_URL:-http://directus:8055}
|
DIRECTUS_URL: ${DIRECTUS_URL:-http://directus:8055}
|
||||||
container_name: sample-website-app
|
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- infra
|
- infra
|
||||||
@@ -24,7 +23,6 @@ services:
|
|||||||
|
|
||||||
directus:
|
directus:
|
||||||
image: registry.infra.mintel.me/mintel/directus:latest
|
image: registry.infra.mintel.me/mintel/directus:latest
|
||||||
container_name: sample-website-directus
|
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- infra
|
- infra
|
||||||
@@ -55,7 +53,6 @@ services:
|
|||||||
|
|
||||||
directus-db:
|
directus-db:
|
||||||
image: postgres:15-alpine
|
image: postgres:15-alpine
|
||||||
container_name: sample-website-db
|
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- infra
|
- infra
|
||||||
|
|||||||
@@ -20,27 +20,14 @@ ENV DIRECTUS_URL=$DIRECTUS_URL
|
|||||||
RUN pnpm --filter ${APP_NAME:-app} build
|
RUN pnpm --filter ${APP_NAME:-app} build
|
||||||
|
|
||||||
# Production runner image
|
# Production runner image
|
||||||
FROM node:20-alpine AS runner
|
FROM registry.infra.mintel.me/mintel/runtime:latest AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install curl for health checks
|
|
||||||
RUN apk add --no-cache curl
|
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
|
||||||
RUN adduser --system --uid 1001 nextjs
|
|
||||||
|
|
||||||
# Copy standalone output and static files
|
# Copy standalone output and static files
|
||||||
# Note: The path depends on the app name
|
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/${APP_NAME:-app}/public ./apps/${APP_NAME:-app}/public
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/${APP_NAME:-app}/public ./apps/${APP_NAME:-app}/public
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/${APP_NAME:-app}/.next/standalone ./
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/${APP_NAME:-app}/.next/standalone ./
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/${APP_NAME:-app}/.next/static ./apps/${APP_NAME:-app}/.next/static
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/${APP_NAME:-app}/.next/static ./apps/${APP_NAME:-app}/.next/static
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
EXPOSE 3000
|
|
||||||
ENV PORT=3000
|
|
||||||
ENV HOSTNAME="0.0.0.0"
|
|
||||||
|
|
||||||
CMD ["node", "apps/${APP_NAME:-app}/server.js"]
|
CMD ["node", "apps/${APP_NAME:-app}/server.js"]
|
||||||
|
|||||||
19
packages/infra/docker/Dockerfile.runtime
Normal file
19
packages/infra/docker/Dockerfile.runtime
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
FROM node:20-alpine
|
||||||
|
|
||||||
|
# Install essential production utilities
|
||||||
|
RUN apk add --no-cache curl libc6-compat
|
||||||
|
|
||||||
|
# Set standard production environment
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ENV PORT=3000
|
||||||
|
ENV HOSTNAME="0.0.0.0"
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Create non-root user for security
|
||||||
|
RUN addgroup --system --gid 1001 nodejs && \
|
||||||
|
adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
|
# Expose the default Next.js port
|
||||||
|
EXPOSE 3000
|
||||||
@@ -39,7 +39,6 @@ services:
|
|||||||
|
|
||||||
gatekeeper:
|
gatekeeper:
|
||||||
image: registry.infra.mintel.me/mintel/gatekeeper:${IMAGE_TAG:-latest}
|
image: registry.infra.mintel.me/mintel/gatekeeper:${IMAGE_TAG:-latest}
|
||||||
container_name: ${PROJECT_NAME}-gatekeeper
|
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- infra
|
- infra
|
||||||
|
|||||||
Reference in New Issue
Block a user