Skip to content

Commit

Permalink
feat: add prod docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentHardouin committed Oct 7, 2024
1 parent ac336bd commit 2a6bf31
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sample.env
.env
README.md
eslint.config.js
.github
docs
node_modules
tests
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG NODE_VERSION=20.16.0

FROM node:${NODE_VERSION}-alpine as builder
WORKDIR /app

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci

COPY . .

FROM node:${NODE_VERSION}-alpine

WORKDIR /app
USER node

COPY --from=builder /app .

ARG PORT=3000
ENV PORT $PORT
EXPOSE $PORT
39 changes: 39 additions & 0 deletions prod.compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:
postgres-ucpa:
image: postgres:15.8-alpine
container_name: ucpa-postgres
networks:
- back
ports:
- '${UCPA_DATABASE_PORT_API:-5466}:5432'
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: ucpa_facilitator
env_file:
- .env

app-ucpa:
build:
context: .
container_name: app-ucpa
command: >
sh -c "npm run db:migrate && npm start"
networks:
- back
- web
environment:
NODE_ENV: production
env_file:
- .env
labels:
traefik.enable: true
traefik.docker.network: web
traefik.http.routers.ucpa.rule: Host(`${URL}`)
traefik.http.routers.ucpa.entrypoints: websecure
traefik.http.routers.ucpa.tls: true
traefik.http.routers.ucpa.tls.certresolver: letsencrypt

networks:
back:
web:
external: true

Check failure on line 39 in prod.compose.yaml

View workflow job for this annotation

GitHub Actions / ci

Newline required at end of file but not found

0 comments on commit 2a6bf31

Please sign in to comment.