From 29219026792c62ad7c1478ed994d0fc70cfb51e0 Mon Sep 17 00:00:00 2001 From: Oliver Weimar-Drese Date: Sat, 14 Feb 2026 16:42:27 +0100 Subject: [PATCH] finally a good local docker setup fitting production Dockerfile --- dockerfiles/unitopia_dev.dockerfile | 55 +++++++++++++++++++++++++++++ dockerfiles/wm3_local_dev.yml | 15 ++++---- 2 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 dockerfiles/unitopia_dev.dockerfile diff --git a/dockerfiles/unitopia_dev.dockerfile b/dockerfiles/unitopia_dev.dockerfile new file mode 100644 index 0000000..1e9379b --- /dev/null +++ b/dockerfiles/unitopia_dev.dockerfile @@ -0,0 +1,55 @@ +# Dockerfile for webmud3 (dev version!!!) + +# docker build -f dockerfiles/unitopia_dev.dockerfile -t myonara/webmud3:develop --progress-plain . + +# Stage 1: Build the application in a monorepo structure +FROM node:22.20.0-alpine AS builder + +# Set the working directory +WORKDIR /app + +# To leverage Docker layer caching, we first copy over all package.json files +# from the monorepo. This ensures that 'npm ci' has the full context of all +# workspaces and their dependencies. +COPY package.json package-lock.json ./ +COPY shared/package.json shared/ +COPY backend/package.json backend/ +COPY frontend/package.json frontend/ + +# Install all dependencies for the entire monorepo +RUN npm ci + +# Copy the rest of the source code +COPY . . + +# Run the production build. This should build all workspaces (frontend, backend, shared). +# The --if-present flag prevents errors if the script doesn't exist. +RUN npm run build --if-present + +# This is the implementation of the step from your Azure workflow. +# It's a workaround to make the 'shared' package available to the backend at runtime +# without publishing it to a package registry. +RUN mkdir -p backend/dist/node_modules/@webmud3 && \ + cp -r shared/dist backend/dist/node_modules/@webmud3/shared && \ + cp shared/package.json backend/dist/node_modules/@webmud3/shared/ +# This step creates a production-only node_modules folder directly within the +# backend's distribution folder, mirroring the Azure deployment process. +RUN cd backend/dist && npm install --omit=dev + +# Stage 2: Create the final production image +FROM node:22.20.0-alpine + +WORKDIR /app + +# Set default environment variables based on the README +ENV NODE_ENV=production HOST=0.0.0.0 PORT=5000 TELNET_HOST=127.0.0.1 TELNET_PORT=23 TELNET_TLS=false SOCKET_ROOT=/socket.io SOCKET_TIMEOUT=900000 + +# Copy the built backend application, including its production node_modules, +# from the builder stage. +COPY --from=builder /app/backend/dist . + +EXPOSE 5000 + +# The command to start the backend server. +# Note: "main.js" is a common convention, but you may need to adjust this based on your project's entrypoint. +CMD [ "node", "main.js" ] diff --git a/dockerfiles/wm3_local_dev.yml b/dockerfiles/wm3_local_dev.yml index bbb2fe6..9ca525c 100644 --- a/dockerfiles/wm3_local_dev.yml +++ b/dockerfiles/wm3_local_dev.yml @@ -3,14 +3,17 @@ services: web: image: myonara/webmud3:develop environment: + ENVIRONMENT: 'development' NODE_ENV: 'development' + NAME: 'webmud3myonara' HOST: '0.0.0.0' PORT: 5000 - TELNET_HOST: 'localhost' - TELNET_PORT: 3333 - TELNET_TLS: 'false' - SOCKET_ROOT: '/mysocket.io' + TELNET_HOST: 'unitopia.de' + TELNET_PORT: 9988 + TELNET_TLS: 'true' + SOCKET_ROOT: '/mysocket-local.io' SOCKET_TIMEOUT: 900000 + LOG_LEVEL: 'debug' deploy: replicas: 1 resources: @@ -20,14 +23,14 @@ services: labels: com.docker.lb.hosts: www.unitopia.de com.docker.lb.network: webnet - com.docker.lb.port: 2018 + com.docker.lb.port: 5000 restart_policy: condition: on-failure delay: 20s max_attempts: 2 window: 3600s ports: - - "2018:5000" + - "5000:5000" networks: - webnet networks: