From a54f751329a512dfdfdad1d874eabe40e99227c1 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Fri, 13 Mar 2026 18:59:08 -0300 Subject: [PATCH 1/7] feat: use nginx instead of vite preview --- Dockerfile | 14 +++++++++----- docker-compose.yml | 4 ++-- nginx.conf | 10 ++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index d5ef27c..5c2f2b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Node Alpine -- multi-arch (amd64 + arm64) -FROM node:lts-alpine +FROM node:lts-alpine AS builder WORKDIR /app @@ -25,8 +25,12 @@ COPY . . # Build the project (Bun is now available for "bun x neu build") RUN bun run build -# Expose Vite preview port -EXPOSE 4173 +# Serve with nginx +FROM nginx:alpine -# Run the built project -CMD ["bun", "run", "preview", "--", "--host", "0.0.0.0"] +COPY --from=builder /app/dist /usr/share/nginx/html + +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Expose the nginx port +EXPOSE 80 diff --git a/docker-compose.yml b/docker-compose.yml index 02fe95e..5459689 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: dockerfile: Dockerfile container_name: monochrome ports: - - '${MONOCHROME_PORT:-3000}:4173' + - '${MONOCHROME_PORT:-3000}:80' environment: AUTH_ENABLED: ${AUTH_ENABLED:-false} AUTH_SECRET: ${AUTH_SECRET:-} @@ -18,7 +18,7 @@ services: networks: - monochrome-network healthcheck: - test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:4173/health'] + test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:80/'] interval: 30s timeout: 3s retries: 3 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7d7bf3a --- /dev/null +++ b/nginx.conf @@ -0,0 +1,10 @@ +server { + listen 80; + listen [::]:80; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + } +} From 51e5086e07781ac57465b3dbb0de0c06af778f14 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Fri, 13 Mar 2026 23:15:46 -0300 Subject: [PATCH 2/7] change container port from 80 to 4173 --- Dockerfile | 2 +- docker-compose.yml | 4 ++-- nginx.conf | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5c2f2b4..17ac9fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,4 +33,4 @@ COPY --from=builder /app/dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf # Expose the nginx port -EXPOSE 80 +EXPOSE 4173 diff --git a/docker-compose.yml b/docker-compose.yml index 5459689..bdf5a2c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: dockerfile: Dockerfile container_name: monochrome ports: - - '${MONOCHROME_PORT:-3000}:80' + - '${MONOCHROME_PORT:-3000}:4173' environment: AUTH_ENABLED: ${AUTH_ENABLED:-false} AUTH_SECRET: ${AUTH_SECRET:-} @@ -18,7 +18,7 @@ services: networks: - monochrome-network healthcheck: - test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:80/'] + test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:4173/'] interval: 30s timeout: 3s retries: 3 diff --git a/nginx.conf b/nginx.conf index 7d7bf3a..eec65a6 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,6 +1,6 @@ server { - listen 80; - listen [::]:80; + listen 4173; + listen [::]:4173; location / { root /usr/share/nginx/html; From 2a054895a8f89f2eb6daec4f4fc810ba797c17e1 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Fri, 13 Mar 2026 23:18:33 -0300 Subject: [PATCH 3/7] don't route missing asset requests to index.html --- nginx.conf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nginx.conf b/nginx.conf index eec65a6..ee8500d 100644 --- a/nginx.conf +++ b/nginx.conf @@ -2,9 +2,14 @@ server { listen 4173; listen [::]:4173; + root /usr/share/nginx/html; + index index.html; + + location ~* \.(?:css|js|mjs|map|json|wasm|mp3|flac|png|jpg|jpeg|svg|webp|ico|gz|br)$ { + try_files $uri =404; + } + location / { - root /usr/share/nginx/html; - index index.html; try_files $uri $uri/ /index.html; } } From ccb628f5161554da66aebe621bc4eb308d08dfe2 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Fri, 13 Mar 2026 23:24:32 -0300 Subject: [PATCH 4/7] nginx: add explicit command for nginx --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 17ac9fa..2fca561 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,3 +34,5 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf # Expose the nginx port EXPOSE 4173 + +CMD ["nginx", "-g", "daemon off;"] From 54540f8fafe1e7225ce0132d4c93d2209a532351 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Fri, 13 Mar 2026 23:25:11 -0300 Subject: [PATCH 5/7] nginx: add more extensions to the static asset pattern --- nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index ee8500d..9122c6a 100644 --- a/nginx.conf +++ b/nginx.conf @@ -5,7 +5,7 @@ server { root /usr/share/nginx/html; index index.html; - location ~* \.(?:css|js|mjs|map|json|wasm|mp3|flac|png|jpg|jpeg|svg|webp|ico|gz|br)$ { + location ~* \.(?:css|js|mjs|map|json|wasm|mp3|flac|wav|ogg|png|jpg|jpeg|svg|webp|ico|gz|br|utf|ttf|woff2?)$ { try_files $uri =404; } From d06aaf724666b2f314242425c68618b6efe44a43 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Fri, 13 Mar 2026 23:45:39 -0300 Subject: [PATCH 6/7] docker: pin images to specific versions for more reproducibility --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2fca561..0881148 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Node Alpine -- multi-arch (amd64 + arm64) -FROM node:lts-alpine AS builder +FROM node:24.14-alpine AS builder WORKDIR /app @@ -26,7 +26,7 @@ COPY . . RUN bun run build # Serve with nginx -FROM nginx:alpine +FROM nginx:1.28.2-alpine COPY --from=builder /app/dist /usr/share/nginx/html From b6853227be91fc0fdfe0c2c1db2cd96c357f2a4e Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Sat, 14 Mar 2026 00:09:05 -0300 Subject: [PATCH 7/7] docker: replace node base image with oven/bun --- Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0881148..508dd58 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Node Alpine -- multi-arch (amd64 + arm64) -FROM node:24.14-alpine AS builder +FROM oven/bun:1.3.10-alpine AS builder WORKDIR /app @@ -7,12 +7,6 @@ WORKDIR /app RUN apk add --no-cache wget curl bash RUN apk add --no-cache python3 make g++ && ln -sf python3 /usr/bin/python -# Install Bun -RUN curl -fsSL https://bun.sh/install | bash - -# Add Bun to PATH so it can be used in subsequent steps -ENV PATH="/root/.bun/bin:${PATH}" - # Copy package files first for caching COPY package.json package-lock.json ./