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
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# production
build
data
output

# python
__pycache__
.pytest_cache
.venv
.poetry

# misc
.DS_Store

# config
config/local.json
.envrc

# logs
gobble.log
s3_upload.log
75 changes: 75 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: container

on:
pull_request:
paths:
- Containerfile
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
env:
MBTA_V3_API_KEY: ${{ secrets.MBTA_V3_API_KEY }}
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build container image
uses: docker/build-push-action@v6
with:
context: .
file: ./Containerfile
push: false
tags: gobble:test
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_ABR_VERSION=${{ github.sha }}

- name: Create config file
run: |
cat >> ./local.json << EOF
{
"mbta": {
"v3_api_key": "${{ secrets.MBTA_V3_API_KEY }}"
},
"modes": ["cr", "bus"],
"gtfs": {
"refresh_interval_days": 7
},
"DATADOG_TRACE_ENABLED": true
}
EOF

- name: Test container starts successfully
run: |
# Start the container in the background
docker run -d \
-v ./local.json:/app/config/local.json:z \
-v ./data:/app/data:z \
--name gobble \
gobble:test

# Wait for the container to start
sleep 10

# Check if container is still running
if ! docker ps | grep -q gobble; then
echo "Container failed to start"
docker logs gobble
exit 1
fi

# Check if there are any files in data directory
find data -type f -print -quit || exit 1

# Cleanup
docker stop gobble
docker rm gobble
18 changes: 18 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.12-slim

WORKDIR /app

# Install uv for Python dependency management
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Copy source code
COPY . .

# Install dependencies
RUN uv sync

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app/src

ENTRYPOINT ["uv", "run", "python3", "src/gobble.py"]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# gobble
![lint](https://github.com/transitmatters/gobble/actions/workflows/lint.yml/badge.svg?branch=main)
![test](https://github.com/transitmatters/gobble/actions/workflows/test.yml/badge.svg?branch=main)
![deploy](https://github.com/transitmatters/gobble/actions/workflows/deploy.yml/badge.svg?branch=main)

![Screenshot in action](docs/screenshot.png)

Expand All @@ -18,6 +19,20 @@ Gobble is a service that reads the [MBTA V3 Streaming API](https://www.mbta.com/
3. Run `uv run src/gobble.py` to start.
4. Output will be in `data/` in your current working directory. Good luck!

### Container

You can also run Gobble inside a container using the following `docker build` and `docker run` commands

```bash
docker build -t gobble -f Containerfile .
docker run \
-v ./config/local.json:/app/config/local.json:z \
-v ./data:/app/data:z \
gobble:latest
```

Output will be in `data/` in your current working directory. Good luck!

### Linting

You can run the linter against any code changes with the following commands
Expand Down