Skip to content

Commit ec18919

Browse files
feat: add prod docker compose
1 parent 0188620 commit ec18919

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

.dockerignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sample.env
2+
.env
3+
README.md
4+
eslint.config.js
5+
.github
6+
docs
7+
node_modules
8+
tests

Dockerfile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ARG NODE_VERSION=20.16.0
2+
3+
FROM node:${NODE_VERSION}-alpine as builder
4+
WORKDIR /app
5+
6+
# Download dependencies as a separate step to take advantage of Docker's caching.
7+
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
8+
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
9+
# into this layer.
10+
RUN --mount=type=bind,source=package.json,target=package.json \
11+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
12+
--mount=type=cache,target=/root/.npm \
13+
npm ci
14+
15+
COPY . .
16+
17+
FROM node:${NODE_VERSION}-alpine
18+
19+
WORKDIR /app
20+
USER node
21+
22+
COPY --from=builder /app .
23+
24+
ARG PORT=3000
25+
ENV PORT $PORT
26+
EXPOSE $PORT

prod.compose.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
services:
2+
postgres-ucpa:
3+
image: postgres:15.8-alpine
4+
container_name: ucpa-postgres
5+
networks:
6+
- back
7+
ports:
8+
- '${UCPA_DATABASE_PORT_API:-5466}:5432'
9+
environment:
10+
POSTGRES_HOST_AUTH_METHOD: trust
11+
POSTGRES_DB: ucpa_facilitator
12+
env_file:
13+
- .env
14+
15+
app-ucpa:
16+
build:
17+
context: .
18+
container_name: app-ucpa
19+
command: >
20+
sh -c "npm run db:migrate && npm start"
21+
networks:
22+
- back
23+
- web
24+
environment:
25+
NODE_ENV: production
26+
env_file:
27+
- .env
28+
labels:
29+
traefik.enable: true
30+
traefik.docker.network: web
31+
traefik.http.routers.ucpa.rule: Host(`${URL}`)
32+
traefik.http.routers.ucpa.entrypoints: websecure
33+
traefik.http.routers.ucpa.tls: true
34+
traefik.http.routers.ucpa.tls.certresolver: letsencrypt
35+
36+
networks:
37+
back:
38+
web:
39+
external: true

0 commit comments

Comments
 (0)