-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating simple dev environment using docker compose
- Loading branch information
Showing
3 changed files
with
10,073 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## To launch | ||
|
||
``` | ||
docker compose up --build -d | ||
``` | ||
|
||
## To connect to the database: | ||
|
||
``` | ||
docker exec -it docker-db-1 psql -U fastapi_traefik -d fastapi_traefik | ||
``` | ||
|
||
The FastAPI application is available at ```http://localhost:8008``` | ||
|
||
Traefik interface is available at ```http://localhost:8081``` | ||
|
||
PgAdmin4 is available at ```http://localhost:8888``` | ||
|
||
## To import data from data set | ||
|
||
> To be executed only once as the postgres server container has a persistent volume attached to it. | ||
``` | ||
fastapi_traefik=# \COPY gladiators (name, age, birth_year, origin, height, weight, category, wins, losses, special_skills, weapon_of_choice, patron_wealth, equipment_quality, public_favor, injury_history, mental_resilience, diet_and_nutrition, tactical_knowledge, allegiance_network, battle_experience, psychological_profile, health_status, personal_motivation, previous_occupation, training_intensity, battle_strategy, social_standing, crowd_appeal_techniques, survived) FROM '/gladiator_data.csv' DELIMITER ',' CSV HEADER; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
version: '3.8' | ||
|
||
services: | ||
web: | ||
build: ../app | ||
command: '-m uvicorn app.main:app --host 0.0.0.0' | ||
volumes: | ||
- ..:/app | ||
expose: | ||
- 8000 | ||
environment: | ||
- DATABASE_URL=postgresql://fastapi_traefik:fastapi_traefik@db:5432/fastapi_traefik | ||
depends_on: | ||
- db | ||
labels: | ||
- "traefik.enable=true" | ||
- "traefik.http.routers.fastapi.rule=Host(`fastapi.localhost`)" | ||
db: | ||
image: postgres:15-alpine | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data/ | ||
- ./gladiator_data.csv:/gladiator_data.csv | ||
expose: | ||
- 5432 | ||
environment: | ||
- POSTGRES_USER=fastapi_traefik | ||
- POSTGRES_PASSWORD=fastapi_traefik | ||
- POSTGRES_DB=fastapi_traefik | ||
pgadmin: | ||
image: dpage/pgadmin4 | ||
container_name: pgadmin4_container | ||
restart: always | ||
ports: | ||
- "127.0.0.1:8888:80" | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: user@domain-name.com | ||
PGADMIN_DEFAULT_PASSWORD: strong-password | ||
traefik: | ||
image: traefik:v2.9.6 | ||
ports: | ||
- 127.0.0.1:8008:80 | ||
- 127.0.0.1:8081:8080 | ||
volumes: | ||
- "../traefik/traefik.dev.toml:/etc/traefik/traefik.toml" | ||
- "/var/run/docker.sock:/var/run/docker.sock:ro" | ||
|
||
volumes: | ||
postgres_data: |
Oops, something went wrong.