-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose-dev.yml
43 lines (39 loc) · 1.51 KB
/
docker-compose-dev.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
# Docker compose version
version: "3"
# Container called api. "build" in the current directory (.). Ports to open (array or dashes. Syntax <port on localhost>:<port on container>),
# if we recieve traffic from localhost we forward it to the port on the container. Port is the one our app listens to.
services:
api:
# Command to create the tables in the postgres container using alembic
command: bash -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
build: .
depends_on:
- postgres
ports:
- 8000:8000
volumes:
# path_folder_to_sync_local_machine : container_folder : read_only
- ./:/usr/src/app/:ro
# env_file:
# - ./.env
environment:
- DATABASE_HOSTNAME=postgres
- DATABASE_PORT=5432
- DATABASE_PASSWORD=nicopostgres
- DATABASE_NAME=fastapi
- DATABASE_USERNAME=postgres
- SECRET_KEY=09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7
- ALGORITHM=HS256
- ACCESS_TOKEN_EXPIRE_MINUTES=30
postgres:
image: postgres
environment:
# Credentails don't have to be the same as in the local machine
- POSTGRES_PASSWORD=nicopostgres
- POSTGRES_DB=fastapi
volumes:
# Path in the container that postgres is going to write to (local machine). postgres-db is the name we give to the volume
- postgres-db:/var/lib/postgresql/data
# Globally define where the app is going to write to. Multiple containers can acces to volumes
volumes:
postgres-db: