From d5afc5997362d567b4ec57e59ede4b1d20b94c2a Mon Sep 17 00:00:00 2001 From: Viswamedha Nalabotu Date: Mon, 10 Nov 2025 15:52:18 +0000 Subject: [PATCH] Added production docker setup --- .gitignore | 4 +++- compose/prod/api/Dockerfile | 26 ++++++++++++++++++++++++++ compose/prod/docker-compose.yml | 31 +++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 compose/prod/api/Dockerfile create mode 100644 compose/prod/docker-compose.yml diff --git a/.gitignore b/.gitignore index 451ee72..85e68d9 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,6 @@ Thumbs.db .github/instructions/nx.instructions.md vite.config.*.timestamp* -vitest.config.*.timestamp* \ No newline at end of file +vitest.config.*.timestamp* + +.env \ No newline at end of file diff --git a/compose/prod/api/Dockerfile b/compose/prod/api/Dockerfile new file mode 100644 index 0000000..77f1446 --- /dev/null +++ b/compose/prod/api/Dockerfile @@ -0,0 +1,26 @@ +FROM node:18-alpine AS builder + +WORKDIR /app + +LABEL org.opencontainers.image.source="TBC" +LABEL org.opencontainers.image.description="FYP Image" + +COPY package*.json ./ + +RUN npm ci + +COPY . . + +RUN npm run build:api + +FROM node:18-alpine + +WORKDIR /app + +RUN npm install -g serve + +COPY --from=builder /app/dist /app/dist + +CMD ["serve", "-s", "dist", "-l", "3000"] + +EXPOSE 3000 \ No newline at end of file diff --git a/compose/prod/docker-compose.yml b/compose/prod/docker-compose.yml new file mode 100644 index 0000000..90c0e34 --- /dev/null +++ b/compose/prod/docker-compose.yml @@ -0,0 +1,31 @@ + + +services: + fyp-web: + image: ${IMAGE} + restart: unless-stopped + deploy: + mode: replicated + replicas: ${REPLICAS} + labels: + - "traefik.enable=true" + - "traefik.http.routers.web-fishy.rule=Host(`${DOMAIN}`)" + - "traefik.http.routers.web-fishy.entrypoints=${ENTRYPOINT}" + - "traefik.http.routers.web-fishy.tls.certresolver=${CERTRESOLVER}" + - "com.centurylinklabs.watchtower.enable=true" + networks: + - proxy + + fyp-watchtower: + image: containrrr/watchtower + command: + - "--label-enable" + - "--interval" + - "30" + - "--rolling-restart" + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + +networks: + proxy: + external: true \ No newline at end of file