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
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.git
.github
.context
.venv
.pytest_cache
.ruff_cache
__pycache__
tests
*.pyc
*.pyo
*.pyd
.DS_Store
.gitignore
Makefile
README.md
42 changes: 42 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Publish Docker Image

on:
push:
tags:
- '*.*.*'

permissions:
contents: read
packages: write

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
flavor: |
latest=true
tags: |
type=sha,prefix=
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM python:3.12-slim
FROM python:3.13-slim

# Install uv.
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Copy the application into the container.
COPY . /app
COPY --from=ghcr.io/astral-sh/uv:0.11 /uv /uvx /bin/

# Install the application dependencies.
WORKDIR /app
COPY pyproject.toml uv.lock /app/
RUN uv sync --frozen --no-cache

# Copy the application into the container.
COPY . /app

# Run the application.
CMD ["/app/.venv/bin/fastapi", "run", "app/main.py", "--port", "80", "--host", "0.0.0.0"]
CMD ["/app/.venv/bin/fastapi", "run", "app/main.py", "--port", "80", "--host", "0.0.0.0"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ start:
uv run fastapi dev app/main.py

build-docker:
docker build -t ecologits-api
docker build -t ecologits-api .

run-docker:
docker run -p 8000:80 ecologits-api
Expand Down
15 changes: 15 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Release
1. Update version number in `pyproject.toml` and `app/core/config.py`.
2. Run `uv lock`
3. Commit, tag and push changes.
```shell
git add .
git commit -m "chore: bump version to x.y.z"
git push origin # wait for all CI jobs to succeed
git tag x.y.z
git push origin --tags
```
4. Go to GitHub in the tags section, on the latest tag click "Create release".
5. Click on "Generate release notes" and review the changelog.
6. Click "Publish release".
7. Go to GitHub Actions and check that the Docker publish job succeeded.
Loading