api: containerize api project
This was actually quite fun, not gonna lie
Pedro Lucas Porcellis porcellis@eletrotupi.com · 6 months ago
1218f83980fd70d63c7e712812eb51d13e902cb2 Browse filesParents
76fe3a3Changed files
4
Additions
+59
Deletions
0
/dev/null → .dockerignore
1 +
api/node_modules
2 +
frontend
/dev/null → api/.dockerignore
1 +
node_modules
/dev/null → api/Dockerfile
1 +
FROM node:24-alpine3.23
2 +
3 +
RUN apk add -U bash postgresql17-client build-base yaml-dev
4 +
5 +
ARG UID=1000
6 +
ARG GID=1000
7 +
8 +
USER "${UID}:${GID}"
9 +
10 +
WORKDIR /app
11 +
12 +
COPY --chown="${UID}:${GID}" package*.json .
13 +
14 +
RUN npm i --frozen-lockfile
15 +
16 +
COPY --chown="${UID}:${GID}" . .
17 +
18 +
EXPOSE 3000
19 +
20 +
CMD ["npm", "run", "dev"]
/dev/null → docker-compose.yml
1 +
services:
2 +
orbit_db:
3 +
image: postgres:17-alpine
4 +
shm_size: 1g
5 +
user: postgres
6 +
restart: always
7 +
healthcheck:
8 +
test: "pg_isready -U user --dbname=postgres"
9 +
interval: 10s
10 +
timeout: 5s
11 +
retries: 5
12 +
ports:
13 +
- 5430:5432
14 +
environment:
15 +
POSTGRES_USER: user
16 +
POSTGRES_DB: orbit_dev
17 +
POSTGRES_PASSWORD: password
18 +
volumes:
19 +
- db_data:/var/lib/postgresql/data
20 +
21 +
orbit_api:
22 +
build: ./api
23 +
volumes:
24 +
- ./api:/app
25 +
- /app/node_modules
26 +
ports:
27 +
- 3000:3000
28 +
env_file:
29 +
- api/.env
30 +
depends_on:
31 +
orbit_db:
32 +
condition: service_healthy
33 +
restart: always
34 +
35 +
volumes:
36 +
db_data: