-
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.
Merge branch 'main' into silopolis/docs_setup
- Loading branch information
Showing
2 changed files
with
92 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,45 @@ | ||
# Application local development environment setup | ||
|
||
|
||
To ease daily local development and testing, the application, together with its database and proxy, can be launched and managed using Docker Compose. | ||
|
||
Docker and Docker Compose must be installed and working on the local machine. | ||
|
||
- **Clone repository** | ||
|
||
```console | ||
git clone https://github.com/DevOps-Boot/fastapi-k8s.git | ||
``` | ||
|
||
- **Change to dev directory** | ||
|
||
```console | ||
cd fastapi-k8s/dev/ | ||
``` | ||
|
||
- **Launch the application** | ||
|
||
```console | ||
docker compose up --build -d | ||
``` | ||
|
||
To relaunch the application as code changes, the environment must be restarted and rebuilt: | ||
|
||
```console | ||
docker compose stop | ||
docker compose up --build -d | ||
``` | ||
|
||
Once application is launched: | ||
|
||
* 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 connect directly to the database CLI, use the following command: | ||
|
||
```console | ||
docker exec -it docker-db-1 psql -U fastapi_traefik -d fastapi_traefik | ||
``` |
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,47 @@ | ||
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/ | ||
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: [email protected] | ||
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: |