File tree Expand file tree Collapse file tree 4 files changed +128
-0
lines changed
Expand file tree Collapse file tree 4 files changed +128
-0
lines changed Original file line number Diff line number Diff line change 1+ # production
2+ build
3+ data
4+ output
5+
6+ # python
7+ __pycache__
8+ .pytest_cache
9+ .venv
10+ .poetry
11+
12+ # misc
13+ .DS_Store
14+
15+ # config
16+ config /local.json
17+ .envrc
18+
19+ # logs
20+ gobble.log
21+ s3_upload.log
Original file line number Diff line number Diff line change 1+ name : container
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - Containerfile
7+ push :
8+ branches :
9+ - main
10+
11+ jobs :
12+ build :
13+ runs-on : ubuntu-latest
14+ env :
15+ MBTA_V3_API_KEY : ${{ secrets.MBTA_V3_API_KEY }}
16+ steps :
17+ - name : Checkout repo
18+ uses : actions/checkout@v3
19+
20+ - name : Set up Docker Buildx
21+ uses : docker/setup-buildx-action@v3
22+
23+ - name : Build container image
24+ uses : docker/build-push-action@v6
25+ with :
26+ context : .
27+ file : ./Containerfile
28+ push : false
29+ tags : gobble:test
30+ load : true
31+ cache-from : type=gha
32+ cache-to : type=gha,mode=max
33+ build-args : |
34+ GIT_ABR_VERSION=${{ github.sha }}
35+
36+ - name : Create config file
37+ run : |
38+ cat >> ./local.json << EOF
39+ {
40+ "mbta": {
41+ "v3_api_key": "${{ secrets.MBTA_V3_API_KEY }}"
42+ },
43+ "modes": ["cr", "bus"],
44+ "gtfs": {
45+ "refresh_interval_days": 7
46+ },
47+ "DATADOG_TRACE_ENABLED": true
48+ }
49+
50+ - name : Test container starts successfully
51+ run : |
52+ # Start the container in the background
53+ docker run -d \
54+ -v ./config/local.json:/app/config/local.json:z \
55+ -v ./data:/app/data:z \
56+ --name gobble \
57+ gobble:test
58+
59+ # Wait for the container to start
60+ sleep 10
61+
62+ # Check if container is still running
63+ if ! docker ps | grep -q gobble; then
64+ echo "Container failed to start"
65+ docker logs gobble
66+ exit 1
67+ fi
68+
69+ # Check if there are any files in data directory
70+ find data -type f -print -quit || exit 1
71+
72+ # Cleanup
73+ docker stop gobble
74+ docker rm gobble
Original file line number Diff line number Diff line change 1+ FROM python:3.12-slim
2+
3+ WORKDIR /app
4+
5+ # Install uv for Python dependency management
6+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
7+
8+ # Copy source code
9+ COPY . .
10+
11+ # Install dependencies
12+ RUN uv sync
13+
14+ # Set environment variables
15+ ENV PYTHONUNBUFFERED=1
16+ ENV PYTHONPATH=/app/src
17+
18+ ENTRYPOINT ["uv" , "run" , "python3" , "src/gobble.py" ]
Original file line number Diff line number Diff line change 11# gobble
22![ lint] ( https://github.com/transitmatters/gobble/actions/workflows/lint.yml/badge.svg?branch=main )
33![ test] ( https://github.com/transitmatters/gobble/actions/workflows/test.yml/badge.svg?branch=main )
4+ ![ deploy] ( https://github.com/transitmatters/gobble/actions/workflows/deploy.yml/badge.svg?branch=main )
45
56![ Screenshot in action] ( docs/screenshot.png )
67
@@ -18,6 +19,20 @@ Gobble is a service that reads the [MBTA V3 Streaming API](https://www.mbta.com/
18193 . Run ` uv run src/gobble.py ` to start.
19204 . Output will be in ` data/ ` in your current working directory. Good luck!
2021
22+ ### Container
23+
24+ You can also run Gobble inside a container using the following ` docker build ` and ` docker run ` commands
25+
26+ ``` bash
27+ docker build -t gobble -f Containerfile .
28+ docker run \
29+ -v ./config/local.json:/app/config/local.json:z \
30+ -v ./data:/app/data:z \
31+ gobble:latest
32+ ```
33+
34+ Output will be in ` data/ ` in your current working directory. Good luck!
35+
2136### Linting
2237
2338You can run the linter against any code changes with the following commands
You can’t perform that action at this time.
0 commit comments