From 8d6d92306398a27155e0bb48040f6e4271967be9 Mon Sep 17 00:00:00 2001 From: gilles Date: Sun, 13 Sep 2026 18:18:08 +0200 Subject: [PATCH] build(docker): add Dockerfile with nginx for production deployment --- .dockerignore | 8 ++++++++ Dockerfile | 22 ++++++++++++++++++++++ nginx.conf | 19 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f39c0b0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +node_modules +dist +coverage +.git +.gitignore +Dockerfile +docker-compose*.yml +*.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9e6e29a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM node:22-alpine AS build + +WORKDIR /app + +RUN corepack enable + +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +RUN pnpm install --frozen-lockfile + +COPY public ./public +COPY . . + +RUN pnpm build + +FROM nginx:1.27-alpine AS production + +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..056aa64 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,19 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + gzip on; + gzip_types text/plain text/css application/json application/javascript image/svg+xml; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(?:js|css|png|jpg|jpeg|gif|svg|ico|woff2?)$ { + expires 30d; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } +} \ No newline at end of file