Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 42 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
FROM node:22.20-alpine3.21 AS ng-build-stage
# Dockerfile for webmud3

# node:20.19-alpine3.20
# 22.20-alpine3.21
# Stage 1: Build the application in a monorepo structure
FROM node:22.20.0-alpine AS builder

# Setze das Arbeitsverzeichnis im Container
WORKDIR /usr/src/app
# Set the working directory
WORKDIR /app

# sourcen kopieren ausser .dockerignore
COPY . /usr/src/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/

# use local sources
RUN npm install && \
npm run build:prod

# fresh small image
FROM node:22.20-alpine3.21 AS webmud3
# Install all dependencies for the entire monorepo
RUN npm ci

# Setze das Arbeitsverzeichnis im Container
WORKDIR /usr/src/app
# Copy the rest of the source code
COPY . .

# kopiere NUR das kompilat
COPY --from=ng-build-stage /usr/src/app/backend/dist /usr/src/app
# 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:prod --if-present

# nondev dependencies mitnehmen
RUN npm install --no-package-lock --omit dev
# 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

# Setze die Umgebungsvariable PORT
ENV PORT=5000
# 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 .

# Exponiere den Port, auf dem die Anwendung läuft
EXPOSE 5000

# Starte die Anwendung
CMD ["node", "main.js"]
# testing CMD ["/bin/sh"]
# 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" ]
2 changes: 2 additions & 0 deletions dockerfiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ docker run -d -p 50000:80 --name helloplain -P nginxdemos/hello:plain-text

docker compose -f dockerfiles/wm_dev_mystiker.yml -p webmud3dev up -d

docker compose -f dockerfiles/wm3_local_dev.yml -p webmud3dev up -d

podman-compose -f dockerfiles/w3_docker_compose.yml -p webmud_unitopia up -d

podman-compose -f dockerfiles/w3_docker_compose_sb.yml -p webmud_seifenblase up -d
Expand Down
35 changes: 35 additions & 0 deletions dockerfiles/wm3_local_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
services:
# docker compose -f dockerfiles/wm3_local_dev.yml -p webmud3dev up -d
web:
image: myonara/webmud3:develop
environment:
NODE_ENV: 'development'
HOST: '0.0.0.0'
PORT: 5000
TELNET_HOST: 'localhost'
TELNET_PORT: 3333
TELNET_TLS: 'false'
SOCKET_ROOT: '/mysocket.io'
SOCKET_TIMEOUT: 900000
deploy:
replicas: 1
resources:
limits:
cpus: "0.1"
memory: 50M
labels:
com.docker.lb.hosts: www.unitopia.de
com.docker.lb.network: webnet
com.docker.lb.port: 2018
restart_policy:
condition: on-failure
delay: 20s
max_attempts: 2
window: 3600s
ports:
- "2018:5000"
networks:
- webnet
networks:
webnet:
driver: bridge
Loading