From 3c949da75ab259a10c11eae2c02b0ac246387fdf Mon Sep 17 00:00:00 2001 From: AdrianoDev Date: Thu, 2 Jul 2026 11:44:42 +0200 Subject: [PATCH] feat: dockerfile multi-stage, compose con traefik per deploy vps --- .dockerignore | 10 ++++++++++ Dockerfile | 23 +++++++++++++++++++++++ compose.yaml | 29 +++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 compose.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..45d7514 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +dist +data +uploads +.env +.git +docs +assets-src +tests +*.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a5963b9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Stage 1: build +FROM node:22-slim AS build +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci +COPY . . +RUN npm run build + +# Stage 2: runtime +FROM node:22-slim AS runtime +WORKDIR /app +ENV NODE_ENV=production +COPY package.json package-lock.json ./ +RUN npm ci --omit=dev && npm cache clean --force +COPY --from=build /app/dist ./dist +COPY scripts ./scripts + +ENV HOST=0.0.0.0 \ + PORT=4321 \ + DB_PATH=/app/data/insanitylab.db \ + UPLOADS_DIR=/app/uploads +EXPOSE 4321 +CMD ["node", "./dist/server/entry.mjs"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..0c9faeb --- /dev/null +++ b/compose.yaml @@ -0,0 +1,29 @@ +services: + insanitylab: + build: . + image: insanitylab-website:latest + container_name: insanitylab + restart: always + env_file: + - .env + environment: + - HOST=0.0.0.0 + - PORT=4321 + - DB_PATH=/app/data/insanitylab.db + - UPLOADS_DIR=/app/uploads + volumes: + - /opt/docker/insanitylab/data:/app/data + - /opt/docker/insanitylab/uploads:/app/uploads + labels: + - traefik.enable=true + - traefik.http.routers.insanitylab.rule=Host(`insanitylab.tielogic.xyz`) + - traefik.http.routers.insanitylab.tls=true + - traefik.http.routers.insanitylab.entrypoints=websecure + - traefik.http.routers.insanitylab.tls.certresolver=mytlschallenge + - traefik.http.services.insanitylab.loadbalancer.server.port=4321 + networks: + - traefik + +networks: + traefik: + external: true