Skip to content
Snippets Groups Projects
Commit fb1b41a0 authored by RichardHeise's avatar RichardHeise
Browse files

Issue #47: HOTFIX docker now works

parent 38839dd5
No related branches found
No related tags found
1 merge request!37Issue #47: HOTFIX docker now works
File moved
FROM node:21-bookworm AS base FROM node:21-bookworm AS base
# -------------------------------------------------------------------------------------- #
# Install dependencies only when needed # Install dependencies only when needed
FROM base AS deps FROM base AS deps
RUN apt install --no-install-recommends libc6 RUN apt-get install --no-install-recommends libc6
WORKDIR /app WORKDIR /app
# Install dependencies based on the preferred package manager # Install dependencies based on the preferred package manager
...@@ -15,11 +16,12 @@ RUN \ ...@@ -15,11 +16,12 @@ RUN \
fi fi
# -------------------------------------------------------------------------------------- #
# Rebuild the source code only when needed # Rebuild the source code only when needed
FROM base AS builder FROM base AS builder
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules /app/node_modules
COPY . . COPY . /app
# Next.js collects completely anonymous telemetry data about general usage. # Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry # Learn more here: https://nextjs.org/telemetry
...@@ -33,6 +35,7 @@ RUN \ ...@@ -33,6 +35,7 @@ RUN \
else echo "Lockfile not found." && exit 1; \ else echo "Lockfile not found." && exit 1; \
fi fi
# -------------------------------------------------------------------------------------- #
# Production image, copy all the files and run next # Production image, copy all the files and run next
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
...@@ -41,28 +44,17 @@ ENV NODE_ENV production ...@@ -41,28 +44,17 @@ ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime. # Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs COPY --from=builder /app/ /app/
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public RUN groupadd --gid 1001 nodejs && useradd --uid 1001 --gid nodejs --shell /bin/bash --create-home nextjs
# Set the correct permission for prerender cache RUN chown nextjs:nodejs /app/.next
RUN mkdir .next
RUN chown nextjs:nodejs .next
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
# We have to remove this lines so npm start will work
# COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
# COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs USER nextjs
WORKDIR /app
EXPOSE 3000
ENV PORT 3000 ENV PORT 3000
# set hostname to localhost EXPOSE 3000
ENV HOSTNAME "0.0.0.0"
# server.js is created by next build from the standalone output # server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output # https://nextjs.org/docs/pages/api-reference/next-config-js/output
......
version: '3.5'
services: services:
app: mecred:
container_name: mecred-frontend
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: frontend-mecred
ports: ports:
- '3000:3000' - '3000:3000'
volumes: volumes:
- .:/app - ./public/:/app/public/
- ./src/:/app/src/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment