From fb1b41a0955a449991262b41e0862646d55bf205 Mon Sep 17 00:00:00 2001 From: RichardHeise <richardfhf5@gmail.com> Date: Fri, 5 Apr 2024 11:33:03 -0300 Subject: [PATCH] Issue #47: HOTFIX docker now works --- .dockereignore => .dockerignore | 0 Dockerfile | 30 +++++++++++------------------- docker-compose.yaml | 10 ++++------ 3 files changed, 15 insertions(+), 25 deletions(-) rename .dockereignore => .dockerignore (100%) diff --git a/.dockereignore b/.dockerignore similarity index 100% rename from .dockereignore rename to .dockerignore diff --git a/Dockerfile b/Dockerfile index ff09b8fa..17ffca5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ FROM node:21-bookworm AS base +# -------------------------------------------------------------------------------------- # # Install dependencies only when needed FROM base AS deps -RUN apt install --no-install-recommends libc6 +RUN apt-get install --no-install-recommends libc6 WORKDIR /app # Install dependencies based on the preferred package manager @@ -15,11 +16,12 @@ RUN \ fi +# -------------------------------------------------------------------------------------- # # Rebuild the source code only when needed FROM base AS builder WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . +COPY --from=deps /app/node_modules /app/node_modules +COPY . /app # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry @@ -33,6 +35,7 @@ RUN \ else echo "Lockfile not found." && exit 1; \ fi +# -------------------------------------------------------------------------------------- # # Production image, copy all the files and run next FROM base AS runner WORKDIR /app @@ -41,28 +44,17 @@ ENV NODE_ENV production # Uncomment the following line in case you want to disable telemetry during runtime. ENV NEXT_TELEMETRY_DISABLED 1 -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs +COPY --from=builder /app/ /app/ -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 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 +RUN chown nextjs:nodejs /app/.next USER nextjs - -EXPOSE 3000 +WORKDIR /app ENV PORT 3000 -# set hostname to localhost -ENV HOSTNAME "0.0.0.0" +EXPOSE 3000 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output diff --git a/docker-compose.yaml b/docker-compose.yaml index ff829c6e..7a6c8296 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,13 +1,11 @@ - -version: '3.5' - services: - app: + mecred: + container_name: mecred-frontend build: context: . dockerfile: Dockerfile - container_name: frontend-mecred ports: - '3000:3000' volumes: - - .:/app + - ./public/:/app/public/ + - ./src/:/app/src/ -- GitLab