Skip to content

Commit c90baf5

Browse files
Merge pull request #2 from moj-analytical-services/feat/uv-in-container
Signed-off-by: Jacob Woffenden <[email protected]>
2 parents eadd610 + 821a380 commit c90baf5

File tree

5 files changed

+149
-19
lines changed

5 files changed

+149
-19
lines changed

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: 🧑‍🔬 Test
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
9+
permissions: {}
10+
11+
jobs:
12+
test:
13+
name: Test
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- name: Checkout
19+
id: checkout
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
persist-credentials: false
23+
24+
- name: Build
25+
id: build
26+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
27+
with:
28+
context: .
29+
push: false
30+
tags: ${{ github.repository }}:${{ github.sha }}
31+
32+
- name: Run
33+
id: run
34+
run: |
35+
docker run ${{ github.repository }}:${{ github.sha }}

Dockerfile

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
FROM ghcr.io/ministryofjustice/analytical-platform-airflow-python-base:1.8.0@sha256:a7d7872482a845e67fc7f78401a6e4a89d906f07d67aca1f7c636cd3c92ae81a
22

3-
# Below is an example of how to use the base image
3+
# https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
4+
ENV UV_COMPILE_BYTECODE=1
45

5-
# Switch to root user to install packages
6-
# USER root
7-
8-
# Copy requirements.txt
9-
# COPY requirements.txt requirements.txt
6+
COPY src/ .
107

11-
# Copy application code
12-
# COPY src/ .
8+
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
9+
--mount=type=bind,source=uv.lock,target=uv.lock \
10+
<<EOF
11+
uv sync --frozen --no-dev --no-editable --no-install-project
12+
EOF
1313

14-
# Install requirements
15-
# RUN <<EOF
16-
# pip install --no-cache-dir --requirement requirements.txt
17-
# EOF
18-
19-
# Switch back to non-root user (analyticalplatform)
20-
# USER ${CONTAINER_UID}
21-
22-
# Execute main.py script
23-
# ENTRYPOINT ["python3", "main.py"]
14+
ENTRYPOINT ["uv", "run", "main.py"]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
88
"boto3==1.37.17",
9+
"notifications-python-client==10.0.1",
910
]

main.py renamed to src/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import boto3
2+
from notifications_python_client.notifications import NotificationsAPIClient
3+
14
def main():
25
print("Hello from analytical-platform-python-uv-example!")
36

uv.lock

Lines changed: 101 additions & 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)