-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
47 lines (41 loc) · 1.08 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
version: "3.8"
volumes:
api-db-data:
networks:
api-network:
services:
db:
container_name: "template_db"
image: postgres:15.3-bullseye
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME}
volumes:
- api-db-data:/var/lib/postgresql/data
- type: tmpfs
target: /dev/shm
ports:
- "${DB_PORT}:5432"
networks:
- api-network
api:
container_name: "template_api"
build:
context: ./
dockerfile: Dockerfile
environment:
- API_PORT=${API_PORT}
- DB_HOST=${DB_HOST}
- DB_USER=${DB_USER}
- DB_PORT=${DB_PORT}
- DB_NAME=${DB_NAME}
- DB_PASSWORD=${DB_PASSWORD}
ports:
- "${API_PORT}:${API_PORT}"
depends_on:
- db
command: >
bash -c "/usr/bin/psql postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT} -c 'drop database if exists ${DB_NAME}' && /usr/bin/psql postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT} -c 'create database ${DB_NAME}'"
networks:
- api-network