From a54f751329a512dfdfdad1d874eabe40e99227c1 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Fri, 13 Mar 2026 18:59:08 -0300 Subject: [PATCH] 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; + } +}