Skip to content

Commit 95da0da

Browse files
Merge pull request #5 from OpenDataServices/2-deployment
Publish docker image
2 parents 18d4994 + 362a631 commit 95da0da

File tree

5 files changed

+162
-0
lines changed

5 files changed

+162
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build and push image
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build-and-push-image:
9+
runs-on: ubuntu-latest
10+
env:
11+
IMAGE_NAME: "oc4ids-datastore-api"
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Login to GitHub Container Registry
15+
uses: docker/login-action@v3
16+
with:
17+
registry: ghcr.io
18+
username: ${{ github.actor }}
19+
password: ${{ secrets.GITHUB_TOKEN }}
20+
- name: Extract version
21+
run: |
22+
TAG=${GITHUB_REF#refs/*/}
23+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
24+
- name: Print version
25+
run: echo $VERSION
26+
- name: Build and push image
27+
run: |
28+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
29+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
30+
echo $IMAGE_ID
31+
docker build . -t ${IMAGE_ID}:${VERSION} -t ${IMAGE_ID}:latest
32+
docker push --all-tags ${IMAGE_ID}

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ jobs:
2323
run: mypy oc4ids_datastore_api/ tests/
2424
- name: Run tests
2525
run: pytest
26+
- name: Build docker image
27+
run: docker build -t oc4ids-datastore-api .

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:3.12-slim
2+
3+
RUN apt-get update \
4+
&& apt-get install -y libpq-dev gcc
5+
6+
WORKDIR /oc4ids_datastore_api
7+
8+
COPY requirements.txt .
9+
10+
RUN pip install -r requirements.txt
11+
12+
COPY . .
13+
14+
RUN pip install .
15+
16+
EXPOSE 8000
17+
18+
ENTRYPOINT ["fastapi", "run", "oc4ids_datastore_api/main.py"]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ isort oc4ids_datastore_api/ tests/
4040
flake8 oc4ids_datastore_api/ tests/
4141
mypy oc4ids_datastore_api/ tests/
4242
```
43+
44+
## Releasing
45+
46+
To publish a new version, raise a PR to `main` updating the version in `pyproject.toml`. Once merged, create a git tag and GitHub release for the new version, with naming `vX.Y.Z`. This will trigger a docker image to to be built and pushed, tagged with the version and `latest`.

requirements.txt

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.12
3+
# by the following command:
4+
#
5+
# pip-compile --output-file=requirements.txt pyproject.toml
6+
#
7+
annotated-types==0.7.0
8+
# via pydantic
9+
anyio==4.8.0
10+
# via
11+
# httpx
12+
# starlette
13+
# watchfiles
14+
certifi==2025.1.31
15+
# via
16+
# httpcore
17+
# httpx
18+
click==8.1.8
19+
# via
20+
# rich-toolkit
21+
# typer
22+
# uvicorn
23+
dnspython==2.7.0
24+
# via email-validator
25+
email-validator==2.2.0
26+
# via fastapi
27+
fastapi[standard]==0.115.8
28+
# via oc4ids-datastore-api (pyproject.toml)
29+
fastapi-cli[standard]==0.0.7
30+
# via fastapi
31+
h11==0.14.0
32+
# via
33+
# httpcore
34+
# uvicorn
35+
httpcore==1.0.7
36+
# via httpx
37+
httptools==0.6.4
38+
# via uvicorn
39+
httpx==0.28.1
40+
# via fastapi
41+
idna==3.10
42+
# via
43+
# anyio
44+
# email-validator
45+
# httpx
46+
jinja2==3.1.5
47+
# via fastapi
48+
markdown-it-py==3.0.0
49+
# via rich
50+
markupsafe==3.0.2
51+
# via jinja2
52+
mdurl==0.1.2
53+
# via markdown-it-py
54+
psycopg2==2.9.10
55+
# via oc4ids-datastore-api (pyproject.toml)
56+
pydantic==2.10.6
57+
# via
58+
# fastapi
59+
# sqlmodel
60+
pydantic-core==2.27.2
61+
# via pydantic
62+
pygments==2.19.1
63+
# via rich
64+
python-dotenv==1.0.1
65+
# via uvicorn
66+
python-multipart==0.0.20
67+
# via fastapi
68+
pyyaml==6.0.2
69+
# via uvicorn
70+
rich==13.9.4
71+
# via
72+
# rich-toolkit
73+
# typer
74+
rich-toolkit==0.13.2
75+
# via fastapi-cli
76+
shellingham==1.5.4
77+
# via typer
78+
sniffio==1.3.1
79+
# via anyio
80+
sqlalchemy==2.0.38
81+
# via sqlmodel
82+
sqlmodel==0.0.22
83+
# via oc4ids-datastore-api (pyproject.toml)
84+
starlette==0.45.3
85+
# via fastapi
86+
typer==0.15.1
87+
# via fastapi-cli
88+
typing-extensions==4.12.2
89+
# via
90+
# anyio
91+
# fastapi
92+
# pydantic
93+
# pydantic-core
94+
# rich-toolkit
95+
# sqlalchemy
96+
# typer
97+
uvicorn[standard]==0.34.0
98+
# via
99+
# fastapi
100+
# fastapi-cli
101+
uvloop==0.21.0
102+
# via uvicorn
103+
watchfiles==1.0.4
104+
# via uvicorn
105+
websockets==14.2
106+
# via uvicorn

0 commit comments

Comments
 (0)