feat: add single-port production docker topology
This commit is contained in:
20
docker/api.Dockerfile
Normal file
20
docker/api.Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM node:24.18.0-bookworm-slim AS build
|
||||
RUN corepack enable && corepack prepare pnpm@10.15.0 --activate
|
||||
WORKDIR /app
|
||||
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
|
||||
COPY backend/package.json backend/package.json
|
||||
COPY frontend/package.json frontend/package.json
|
||||
RUN pnpm install --frozen-lockfile
|
||||
COPY backend backend
|
||||
RUN pnpm --filter backend build:api
|
||||
|
||||
FROM node:24.18.0-bookworm-slim AS runtime
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/node_modules ./node_modules
|
||||
COPY --from=build /app/backend/node_modules ./backend/node_modules
|
||||
COPY --from=build /app/backend/package.json ./backend/package.json
|
||||
COPY --from=build /app/backend/dist ./backend/dist
|
||||
USER node
|
||||
EXPOSE 3000
|
||||
CMD ["node", "backend/dist/apps/api/src/main.js"]
|
||||
15
docker/edge.Dockerfile
Normal file
15
docker/edge.Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM node:24.18.0-bookworm-slim AS frontend-build
|
||||
RUN corepack enable && corepack prepare pnpm@10.15.0 --activate
|
||||
WORKDIR /app
|
||||
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
|
||||
COPY frontend/package.json frontend/package.json
|
||||
COPY backend/package.json backend/package.json
|
||||
RUN pnpm install --frozen-lockfile
|
||||
COPY frontend frontend
|
||||
RUN pnpm --filter frontend build
|
||||
|
||||
FROM nginx:1.29.8-alpine
|
||||
COPY docker/edge/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY docker/edge/default.conf.template /etc/nginx/templates/default.conf.template
|
||||
COPY --from=frontend-build /app/frontend/dist/frontend/browser /usr/share/nginx/html
|
||||
EXPOSE 443
|
||||
29
docker/edge/default.conf.template
Normal file
29
docker/edge/default.conf.template
Normal file
@@ -0,0 +1,29 @@
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name _;
|
||||
|
||||
ssl_certificate /run/tls/tls.crt;
|
||||
ssl_certificate_key /run/tls/tls.key;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://api:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
location /health/ {
|
||||
proxy_pass http://api:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
16
docker/edge/nginx.conf
Normal file
16
docker/edge/nginx.conf
Normal file
@@ -0,0 +1,16 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
19
docker/worker.Dockerfile
Normal file
19
docker/worker.Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM node:24.18.0-bookworm-slim AS build
|
||||
RUN corepack enable && corepack prepare pnpm@10.15.0 --activate
|
||||
WORKDIR /app
|
||||
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
|
||||
COPY backend/package.json backend/package.json
|
||||
COPY frontend/package.json frontend/package.json
|
||||
RUN pnpm install --frozen-lockfile
|
||||
COPY backend backend
|
||||
RUN pnpm --filter backend build:worker
|
||||
|
||||
FROM node:24.18.0-bookworm-slim AS runtime
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/node_modules ./node_modules
|
||||
COPY --from=build /app/backend/node_modules ./backend/node_modules
|
||||
COPY --from=build /app/backend/package.json ./backend/package.json
|
||||
COPY --from=build /app/backend/dist ./backend/dist
|
||||
USER node
|
||||
CMD ["node", "backend/dist/apps/worker/src/main.js"]
|
||||
Reference in New Issue
Block a user