docker image

This commit is contained in:
Elio Bischof
2025-02-10 15:42:23 +01:00
parent cc9cc30695
commit 79b2180df5
3 changed files with 61 additions and 0 deletions

5
.dockerignore Normal file
View File

@@ -0,0 +1,5 @@
node_modules
.git
.gitignore
*.md
dist

55
Dockerfile Normal file
View File

@@ -0,0 +1,55 @@
# Inspired by https://pnpm.io/docker#example-3-build-on-cicd
# Inspired by https://pnpm.io/docker#minimizing-docker-image-size-and-build-time
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apt-get update
RUN apt-get install -y git
RUN npm install -g corepack
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
RUN pnpm install turbo@^2 --global
FROM base AS builder
# Set working directory
WORKDIR /app
# Replace <your-major-version> with the major version installed in your repository. For example:
RUN pnpm install turbo@^2 --global
COPY . .
# Generate a partial monorepo with a pruned lockfile for a target workspace.
# Assuming "web" is the name entered in the project's package.json: { name: "web" }
RUN turbo prune @zitadel/login --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
WORKDIR /app
# First install the dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
RUN pnpm install --frozen-lockfile
# Build the project
COPY --from=builder /app/out/full/ .
RUN turbo run build
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/login/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/login/.next/static ./apps/login/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/login/public ./apps/login/public
ENV HOSTNAME="0.0.0.0"
CMD node apps/login/server.js

View File

@@ -36,6 +36,7 @@ const secureHeaders = [
const nextConfig = { const nextConfig = {
basePath: process.env.NEXT_PUBLIC_BASE_PATH, basePath: process.env.NEXT_PUBLIC_BASE_PATH,
output: 'standalone',
reactStrictMode: true, // Recommended for the `pages` directory, default in `app`. reactStrictMode: true, // Recommended for the `pages` directory, default in `app`.
experimental: { experimental: {
dynamicIO: true, dynamicIO: true,