Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
__pycache__
.venv
*.db
.env
.git
*.pyc
.pytest_cache
Expand Down
7 changes: 5 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
DATABASE_URL=sqlite+aiosqlite:///./trackit.db
DEBUG=False
POSTGRES_USER = <DB_USER>
POSTGRES_PASSWORD = <DB_PASSWORD>
POSTGRES_DB = <DB_NAME>
DATABASE_URL = <DB_URL>
DEBUG = <True/False>
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ name: CI

on:
push:
branches: [ main, develop ]
branches: [ main, dev ]
pull_request:
branches: [ main ]

env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DEBUG: ${{ secrets.DEBUG }}

jobs:
test:
runs-on: ubuntu-latest
Expand Down
30 changes: 25 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
name: Docker Image CI
name: Docker Image

on:
push:
branches: [ "main" ]
branches: [ "main", "dev" ]
pull_request:
branches: [ "main" ]

env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DEBUG: ${{ secrets.DEBUG }}

jobs:

build:
Expand All @@ -14,13 +21,26 @@ jobs:

steps:
- uses: actions/checkout@v6

- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
run: docker build -t trackit-api:latest .

- name: Run docker compose
run: |
docker compose up -d
sleep 10
docker compose up -d --build
sleep 5
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}

- name: Show API logs
run: |
docker logs trackit-api --tail 50

- name: Wait for Postgres
run: |
timeout 60s bash -c 'until docker exec pg-db pg_isready -U trackit; do sleep 1; done'

- name: Check container is running
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ __pycache__
.venv
.pytest_cache
*.db
.env
.env
check-list-docker.md
7 changes: 5 additions & 2 deletions app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
from pydantic import ConfigDict

class Settings(BaseSettings):
DATABASE_URL: str = 'sqlite+aiosqlite:///./trackit.db'
POSTGRES_USER: str
POSTGRES_PASSWORD: str
POSTGRES_DB: str
DATABASE_URL: str
DEBUG: bool = True

model_config = ConfigDict(env_file = '.env', case_sensetive = True)
model_config = ConfigDict(env_file = '.env', case_sensitive = True)

settings = Settings()
23 changes: 19 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
services:
db:
image: postgres:15
container_name: pg-db
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data


api:
build: .
container_name: trackit-api
ports:
- "8000:8000"
environment:
- DATABASE_URL=sqlite+aiosqlite:///./trackit.db
- DEBUG=True
- DATABASE_URL=${DATABASE_URL}
- DEBUG=${DEBUG}
volumes:
- ./trackit.db:/app/trackit.db
- ./app:/app/app
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
restart: unless-stopped
restart: unless-stopped

volumes:
postgres_data:
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ API for tracking habits. Written in FastAPI with asynchronous database operation
```
git clone https://github.com/ghostfaccee/TrackIt-API.git
cd TrackIt-API
touch trackit.db
docker compose up --build
```

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ annotated-doc==0.0.4
annotated-types==0.7.0
anyio==4.14.1
asgi-lifespan==2.1.0
asyncpg==0.31.0
certifi==2026.6.17
click==8.4.2
fastapi==0.138.1
Expand Down