Skip to content

Commit 40833b3

Browse files
authored
Add Docker to the CI (#30)
1 parent be8b694 commit 40833b3

File tree

10 files changed

+42
-24
lines changed

10 files changed

+42
-24
lines changed

.github/workflows/_deploy_api.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@ on:
66
environment:
77
required: true
88
type: string
9+
docker_tag:
10+
required: true
11+
type: string
912

1013
jobs:
1114
deploy:
1215
runs-on: ubuntu-22.04
1316
environment: ${{ inputs.environment }}
1417
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17-
18-
- name: Install uv
19-
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
20-
with:
21-
version: ${{ vars.UV_VERSION }}
22-
23-
- name: Install Python packages
24-
run: uv sync --locked --no-dev
18+
- name: Print docker tag
19+
run: echo "Docker tag:${{ inputs.docker_tag }}"
2520
shell: bash

.github/workflows/pull_request.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
continuous-integration:
1414
if: github.actor != 'dependabot[bot]'
1515
runs-on: ubuntu-latest
16+
outputs:
17+
api-docker-tag: ${{ steps.api-docker-tag.outputs.api-docker-tag }}
1618
env:
1719
COMMON__ENVIRONMENT: Development
1820
steps:
@@ -46,11 +48,26 @@ jobs:
4648
run: uv run --frozen -- pytest -m integration
4749
shell: bash
4850

51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
53+
54+
- name: Set api docker tag
55+
id: api-docker-tag
56+
run: echo "api-docker-tag=myregistry/api:${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
57+
58+
- name: Build and push api
59+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
60+
with:
61+
file: api/src/api/Dockerfile
62+
tags: ${{ steps.api-docker-tag.outputs.api-docker-tag }}
63+
push: false
64+
4965
deploy-api-dev:
5066
needs: continuous-integration
5167
uses: ./.github/workflows/_deploy_api.yaml
5268
with:
5369
environment: dev
70+
docker_tag: ${{ needs.continuous-integration.outputs.api-docker-tag }}
5471
secrets: inherit
5572

5673
deploy-transcriber-dev:
@@ -65,6 +82,7 @@ jobs:
6582
uses: ./.github/workflows/_deploy_api.yaml
6683
with:
6784
environment: stg
85+
docker_tag: ${{ needs.continuous-integration.outputs.api-docker-tag }}
6886
secrets: inherit
6987

7088
deploy-transcriber-stg:
@@ -79,6 +97,7 @@ jobs:
7997
uses: ./.github/workflows/_deploy_api.yaml
8098
with:
8199
environment: pro
100+
docker_tag: ${{ needs.continuous-integration.outputs.api-docker-tag }}
82101
secrets: inherit
83102

84103
deploy-transcriber-pro:

api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name = "api"
33
version = "0.1.0"
44

55
[build-system]
6-
requires = ["uv_build>=0.8.0,<0.9.0"]
6+
requires = ["uv_build>=0.8.11,<0.9.0"]
77
build-backend = "uv_build"

api/src/api/Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
# 0.7.19-python3.12-bookworm-slim
2-
FROM astral/uv@sha256:235c2e8419851c1d539e2b19033d56aaf82670bfaaa155e20ac6b21260dc0be9 AS builder
1+
# 0.8.11-python3.12-bookworm-slim
2+
FROM astral/uv@sha256:165703e3c12d7fca3dfa15b2012b98d6e03c261a516d4bd7ca3a956c57c7abce AS builder
33

44
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=0
55

66
WORKDIR /app
7+
RUN --mount=type=cache,target=/root/.cache/uv \
8+
--mount=type=bind,source=uv.lock,target=uv.lock \
9+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
10+
uv sync --frozen --no-install-workspace --no-dev
711
COPY pyproject.toml uv.lock ./
8-
COPY api api
12+
COPY common common
913
COPY domain domain
14+
COPY api api
1015
RUN --mount=type=cache,target=/root/.cache/uv \
11-
uv sync --locked --no-dev
16+
uv sync --frozen --no-dev
1217

1318
# 3.12.11-slim-bookworm
14-
FROM python@sha256:4600f71648e110b005bf7bca92dbb335e549e6b27f2e83fceee5e11b3e1a4d01 AS final
19+
FROM python@sha256:42cf2422587a3dac0e0a3674a4d86f01570d5d7260588f3845f51e6176d8134b AS final
1520

1621
ENV COMMON__ENVIRONMENT=""
1722

@@ -20,5 +25,4 @@ COPY --from=builder --chown=nonroot /app /app
2025
WORKDIR /app
2126
EXPOSE 8000
2227
USER nonroot
23-
CMD [".venv/bin/poe", "start-api-pro"]
24-
28+
CMD [".venv/bin/poe", "start-api-pro"]

common/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name = "common"
33
version = "0.1.0"
44

55
[build-system]
6-
requires = ["uv_build>=0.8.0,<0.9.0"]
6+
requires = ["uv_build>=0.8.11,<0.9.0"]
77
build-backend = "uv_build"

domain/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name = "domain"
33
version = "0.1.0"
44

55
[build-system]
6-
requires = ["uv_build>=0.8.0,<0.9.0"]
6+
requires = ["uv_build>=0.8.11,<0.9.0"]
77
build-backend = "uv_build"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dev = [
2929
]
3030

3131
[tool.uv]
32-
required-version = ">=0.8.0,<0.9.0"
32+
required-version = ">=0.8.11,<0.9.0"
3333

3434
[tool.uv.workspace]
3535
members = ["api", "domain", "transcriber", "test_utils", "common", "scripts"]

test_utils/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name = "test-utils"
33
version = "0.1.0"
44

55
[build-system]
6-
requires = ["uv_build>=0.8.0,<0.9.0"]
6+
requires = ["uv_build>=0.8.11,<0.9.0"]
77
build-backend = "uv_build"

transcriber/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name = "transcriber"
33
version = "0.1.0"
44

55
[build-system]
6-
requires = ["uv_build>=0.8.0,<0.9.0"]
6+
requires = ["uv_build>=0.8.11,<0.9.0"]
77
build-backend = "uv_build"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)