Skip to content

Commit da681af

Browse files
committed
Add CI workflow, Docker tooling, and deployment docs
1 parent 48c1cf6 commit da681af

3 files changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- develop
9+
pull_request:
10+
11+
jobs:
12+
tests:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -r requirements.txt
27+
28+
- name: Run pytest
29+
run: pytest

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ docker run --rm -p 8000:8000 --env-file .env -v $(pwd)/uploads:/app/uploads imag
5656

5757
Customize `DB_URL`, `UPLOAD_DIR`, etc. via the `--env-file` or individual `-e` flags.
5858

59+
### Docker Compose & Postgres
60+
61+
For a Postgres-backed setup (with uploads persisted to a Docker volume), use the provided composition:
62+
63+
```bash
64+
docker compose up --build
65+
```
66+
67+
Key environment variables for production deployments:
68+
69+
| Variable | Description |
70+
|----------|-------------|
71+
| `DB_URL` | Should point to your managed database, e.g. `postgresql+psycopg2://user:pass@host:5432/dbname`. |
72+
| `UPLOAD_DIR` | Mounted path where files are stored (use a persistent volume or S3-compatible backend). |
73+
| `RATE_LIMIT_PER_MINUTE` | Adjust per-client quotas according to expected traffic. |
74+
| `MAX_FILE_SIZE_BYTES` | Enforce a tighter upload cap if needed. |
75+
| `CACHE_MAX_AGE_SECONDS` | Tune cache headers for served files. |
76+
| `CORS_ORIGINS` | Lock down origins for production frontends. |
77+
| `ENABLE_CLEANER` | Keep true to remove stale files automatically. |
78+
5979
## API Overview
6080

6181
| Method | Path | Description |

docker-compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: "3.9"
2+
3+
services:
4+
app:
5+
build: .
6+
image: image-uploader-app
7+
container_name: image-uploader-app
8+
env_file: .env
9+
environment:
10+
UPLOAD_DIR: /data/uploads
11+
DB_URL: postgresql+psycopg2://cdn:cdn@db:5432/cdn
12+
depends_on:
13+
db:
14+
condition: service_healthy
15+
volumes:
16+
- uploads-data:/data/uploads
17+
ports:
18+
- "8000:8000"
19+
20+
db:
21+
image: postgres:16
22+
restart: always
23+
environment:
24+
POSTGRES_DB: cdn
25+
POSTGRES_USER: cdn
26+
POSTGRES_PASSWORD: cdn
27+
healthcheck:
28+
test: ["CMD-SHELL", "pg_isready -U cdn -d cdn"]
29+
interval: 10s
30+
timeout: 5s
31+
retries: 5
32+
33+
volumes:
34+
uploads-data:

0 commit comments

Comments
 (0)