Skip to content

Commit 77a4b6e

Browse files
committed
feat: add Docker Compose configuration for dev/prod environments with documented usage details
1 parent c541a2c commit 77a4b6e

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ This is because Jupyter notebooks are asynchronous by default.
196196

197197
## 🐳 Self-host
198198

199+
### Using Docker
200+
199201
1. Build the image:
200202

201203
``` bash
@@ -232,6 +234,62 @@ The application can be configured using the following environment variables:
232234
- **GITINGEST_SENTRY_PROFILE_LIFECYCLE**: Profile lifecycle mode (default: "trace")
233235
- **GITINGEST_SENTRY_SEND_DEFAULT_PII**: Send default personally identifiable information (default: "true")
234236

237+
### Using Docker Compose
238+
239+
The project includes a `compose.yml` file that allows you to easily run the application in both development and production environments.
240+
241+
#### Compose File Structure
242+
243+
The `compose.yml` file uses YAML anchoring with `&app-base` and `<<: *app-base` to define common configuration that is shared between services:
244+
245+
```yaml
246+
# Common base configuration for all services
247+
x-app-base: &app-base
248+
build:
249+
context: .
250+
dockerfile: Dockerfile
251+
ports:
252+
- "${APP_WEB_BIND:-8000}:8000" # Main application port
253+
- "${GITINGEST_METRICS_HOST:-127.0.0.1}:${GITINGEST_METRICS_PORT:-9090}:9090" # Metrics port
254+
# ... other common configurations
255+
```
256+
257+
#### Services
258+
259+
The file defines two services:
260+
261+
1. **app**: Production service configuration
262+
- Uses the `prod` profile
263+
- Sets the Sentry environment to "production"
264+
- Configured for stable operation with `restart: unless-stopped`
265+
266+
2. **app-dev**: Development service configuration
267+
- Uses the `dev` profile
268+
- Enables debug mode
269+
- Mounts the source code for live development
270+
- Uses hot reloading for faster development
271+
272+
#### Usage Examples
273+
274+
To run the application in development mode:
275+
276+
```bash
277+
docker compose --profile dev up
278+
```
279+
280+
To run the application in production mode:
281+
282+
```bash
283+
docker compose --profile prod up -d
284+
```
285+
286+
To build and run the application:
287+
288+
```bash
289+
docker compose --profile prod build
290+
docker compose --profile prod up -d
291+
```
292+
235293
## 🤝 Contributing
236294

237295
### Non-technical ways to contribute

compose.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Common base configuration for all services
2+
x-app-base: &app-base
3+
ports:
4+
- "${APP_WEB_BIND:-8000}:8000" # Main application port
5+
- "${GITINGEST_METRICS_HOST:-127.0.0.1}:${GITINGEST_METRICS_PORT:-9090}:9090" # Metrics port
6+
environment:
7+
# Python Configuration
8+
- PYTHONUNBUFFERED=1
9+
- PYTHONDONTWRITEBYTECODE=1
10+
# Host Configuration
11+
- ALLOWED_HOSTS=${ALLOWED_HOSTS:-gitingest.com,*.gitingest.com,localhost,127.0.0.1}
12+
# Metrics Configuration
13+
- GITINGEST_METRICS_ENABLED=${GITINGEST_METRICS_ENABLED:-true}
14+
- GITINGEST_METRICS_HOST=${GITINGEST_METRICS_HOST:-127.0.0.1}
15+
- GITINGEST_METRICS_PORT=${GITINGEST_METRICS_PORT:-9090}
16+
# Sentry Configuration
17+
- GITINGEST_SENTRY_ENABLED=${GITINGEST_SENTRY_ENABLED:-false}
18+
- GITINGEST_SENTRY_DSN=${GITINGEST_SENTRY_DSN:-}
19+
- GITINGEST_SENTRY_TRACES_SAMPLE_RATE=${GITINGEST_SENTRY_TRACES_SAMPLE_RATE:-1.0}
20+
- GITINGEST_SENTRY_PROFILE_SESSION_SAMPLE_RATE=${GITINGEST_SENTRY_PROFILE_SESSION_SAMPLE_RATE:-1.0}
21+
- GITINGEST_SENTRY_PROFILE_LIFECYCLE=${GITINGEST_SENTRY_PROFILE_LIFECYCLE:-trace}
22+
- GITINGEST_SENTRY_SEND_DEFAULT_PII=${GITINGEST_SENTRY_SEND_DEFAULT_PII:-true}
23+
user: "1000:1000"
24+
command: ["python", "-m", "uvicorn", "server.main:app", "--host", "0.0.0.0", "--port", "8000"]
25+
26+
services:
27+
# Production service configuration
28+
app:
29+
<<: *app-base
30+
image: ghcr.io/coderamp-labs/gitingest:latest
31+
profiles:
32+
- prod
33+
environment:
34+
- GITINGEST_SENTRY_ENVIRONMENT=${GITINGEST_SENTRY_ENVIRONMENT:-production}
35+
restart: unless-stopped
36+
37+
# Development service configuration
38+
app-dev:
39+
<<: *app-base
40+
build:
41+
context: .
42+
dockerfile: Dockerfile
43+
profiles:
44+
- dev
45+
environment:
46+
- DEBUG=true
47+
- GITINGEST_SENTRY_ENVIRONMENT=${GITINGEST_SENTRY_ENVIRONMENT:-development}
48+
volumes:
49+
# Mount source code for live development
50+
- ./src:/app:ro
51+
# Use --reload flag for hot reloading during development
52+
command: ["python", "-m", "uvicorn", "server.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

0 commit comments

Comments
 (0)