Skip to content

Commit fc1f386

Browse files
Merge pull request #22 from OpenDataServices/12-deployment
Publish docker image
2 parents 0cf9466 + 40f98e7 commit fc1f386

File tree

9 files changed

+269
-2
lines changed

9 files changed

+269
-2
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-pipeline"
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_pipeline/ tests/
2424
- name: Run tests
2525
run: pytest
26+
- name: Build docker image
27+
run: docker build -t oc4ids-datastore-pipeline .

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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_pipeline
7+
8+
COPY requirements.txt .
9+
10+
RUN pip install -r requirements.txt
11+
12+
COPY . .
13+
14+
RUN pip install .
15+
16+
ENTRYPOINT ["sh", "-c", "alembic upgrade head && oc4ids-datastore-pipeline"]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ pytest
7171
```
7272
alembic revision --autogenerate -m "<MESSAGE HERE>"
7373
```
74+
75+
## Releasing
76+
77+
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`.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""allow nullable json_url
2+
3+
Revision ID: 3499656b84e7
4+
Revises: 084c39bf418e
5+
Create Date: 2025-02-11 16:44:30.550413
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
from alembic import op
12+
import sqlalchemy as sa
13+
14+
15+
# revision identifiers, used by Alembic.
16+
revision: str = "3499656b84e7"
17+
down_revision: Union[str, None] = "084c39bf418e"
18+
branch_labels: Union[str, Sequence[str], None] = None
19+
depends_on: Union[str, Sequence[str], None] = None
20+
21+
22+
def upgrade() -> None:
23+
# ### commands auto generated by Alembic - please adjust! ###
24+
op.alter_column("dataset", "json_url", existing_type=sa.VARCHAR(), nullable=True)
25+
# ### end Alembic commands ###
26+
27+
28+
def downgrade() -> None:
29+
# ### commands auto generated by Alembic - please adjust! ###
30+
op.alter_column("dataset", "json_url", existing_type=sa.VARCHAR(), nullable=False)
31+
# ### end Alembic commands ###

oc4ids_datastore_pipeline/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Dataset(Base):
3030
publisher_name: Mapped[str] = mapped_column(String)
3131
license_url: Mapped[Optional[str]] = mapped_column(String, nullable=True)
3232
license_name: Mapped[Optional[str]] = mapped_column(String, nullable=True)
33-
json_url: Mapped[str] = mapped_column(String)
33+
json_url: Mapped[Optional[str]] = mapped_column(String, nullable=True)
3434
csv_url: Mapped[Optional[str]] = mapped_column(String, nullable=True)
3535
xlsx_url: Mapped[Optional[str]] = mapped_column(String, nullable=True)
3636
updated_at: Mapped[datetime.datetime] = mapped_column(DateTime(timezone=True))

oc4ids_datastore_pipeline/pipeline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def process_registry() -> None:
145145
process_deleted_datasets(registered_datasets)
146146
for name, url in registered_datasets.items():
147147
process_dataset(name, url)
148+
logger.info("Finished processing all datasets")
148149

149150

150151
def run() -> None:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies = [
1313
"flattentool",
1414
"libcoveoc4ids",
1515
"psycopg2",
16+
"python-dotenv",
1617
"requests",
1718
"sqlalchemy",
1819
]
@@ -26,7 +27,6 @@ dev = [
2627
"mypy",
2728
"pytest",
2829
"pytest-mock",
29-
"python-dotenv",
3030
"types-boto3",
3131
"types-requests",
3232
]

requirements.txt

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
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+
alembic==1.14.1
8+
# via oc4ids-datastore-pipeline (pyproject.toml)
9+
attrs==25.1.0
10+
# via
11+
# cattrs
12+
# jsonschema
13+
# referencing
14+
# requests-cache
15+
backports-datetime-fromisoformat==2.0.3
16+
# via flattentool
17+
boto3==1.36.17
18+
# via oc4ids-datastore-pipeline (pyproject.toml)
19+
botocore==1.36.17
20+
# via
21+
# boto3
22+
# s3transfer
23+
btrees==6.1
24+
# via zodb
25+
cattrs==24.1.2
26+
# via requests-cache
27+
certifi==2025.1.31
28+
# via requests
29+
cffi==1.17.1
30+
# via persistent
31+
charset-normalizer==3.4.1
32+
# via requests
33+
click==8.1.8
34+
# via
35+
# libcoveoc4ids
36+
# libcoveocds
37+
defusedxml==0.7.1
38+
# via odfpy
39+
et-xmlfile==2.0.0
40+
# via openpyxl
41+
flattentool==0.27.0
42+
# via
43+
# libcove
44+
# oc4ids-datastore-pipeline (pyproject.toml)
45+
idna==3.10
46+
# via requests
47+
ijson==3.3.0
48+
# via flattentool
49+
jmespath==1.0.1
50+
# via
51+
# boto3
52+
# botocore
53+
json-merge-patch==0.2
54+
# via ocdsextensionregistry
55+
jsonref==1.1.0
56+
# via
57+
# flattentool
58+
# libcove
59+
# libcoveocds
60+
# ocdsextensionregistry
61+
jsonschema==4.23.0
62+
# via
63+
# libcove
64+
# libcoveocds
65+
jsonschema-specifications==2024.10.1
66+
# via jsonschema
67+
libcove==0.32.1
68+
# via
69+
# libcoveoc4ids
70+
# libcoveocds
71+
libcoveoc4ids==0.9.0
72+
# via oc4ids-datastore-pipeline (pyproject.toml)
73+
libcoveocds==0.16.4
74+
# via libcoveoc4ids
75+
lxml==5.3.1
76+
# via flattentool
77+
mako==1.3.9
78+
# via alembic
79+
markupsafe==3.0.2
80+
# via mako
81+
ocdsextensionregistry==0.6.9
82+
# via libcoveocds
83+
odfpy==1.4.1
84+
# via flattentool
85+
openpyxl==3.1.5
86+
# via flattentool
87+
persistent==6.1
88+
# via
89+
# btrees
90+
# zodb
91+
platformdirs==4.3.6
92+
# via requests-cache
93+
psycopg2==2.9.10
94+
# via oc4ids-datastore-pipeline (pyproject.toml)
95+
pycparser==2.22
96+
# via cffi
97+
python-dateutil==2.9.0.post0
98+
# via botocore
99+
python-dotenv==1.0.1
100+
# via oc4ids-datastore-pipeline (pyproject.toml)
101+
pytz==2025.1
102+
# via flattentool
103+
referencing==0.36.2
104+
# via
105+
# jsonschema
106+
# jsonschema-specifications
107+
# libcove
108+
# libcoveocds
109+
requests==2.32.3
110+
# via
111+
# libcove
112+
# libcoveocds
113+
# oc4ids-datastore-pipeline (pyproject.toml)
114+
# ocdsextensionregistry
115+
# requests-cache
116+
requests-cache==1.2.1
117+
# via ocdsextensionregistry
118+
rfc3339-validator==0.1.4
119+
# via libcove
120+
rfc3987==1.3.8
121+
# via libcove
122+
rpds-py==0.22.3
123+
# via
124+
# jsonschema
125+
# referencing
126+
s3transfer==0.11.2
127+
# via boto3
128+
schema==0.7.7
129+
# via flattentool
130+
six==1.17.0
131+
# via
132+
# python-dateutil
133+
# rfc3339-validator
134+
# url-normalize
135+
sqlalchemy==2.0.38
136+
# via
137+
# alembic
138+
# oc4ids-datastore-pipeline (pyproject.toml)
139+
transaction==5.0
140+
# via zodb
141+
typing-extensions==4.12.2
142+
# via
143+
# alembic
144+
# referencing
145+
# sqlalchemy
146+
url-normalize==1.4.3
147+
# via requests-cache
148+
urllib3==2.3.0
149+
# via
150+
# botocore
151+
# requests
152+
# requests-cache
153+
xmltodict==0.14.2
154+
# via flattentool
155+
zc-lockfile==3.0.post1
156+
# via zodb
157+
zc-zlibstorage==1.2.0
158+
# via flattentool
159+
zconfig==4.2
160+
# via zodb
161+
zodb==6.0
162+
# via
163+
# flattentool
164+
# zc-zlibstorage
165+
zodbpickle==4.1.1
166+
# via zodb
167+
zope-deferredimport==5.0
168+
# via persistent
169+
zope-interface==7.2
170+
# via
171+
# btrees
172+
# persistent
173+
# transaction
174+
# zc-zlibstorage
175+
# zodb
176+
# zope-proxy
177+
zope-proxy==6.1
178+
# via zope-deferredimport
179+
180+
# The following packages are considered to be unsafe in a requirements file:
181+
# setuptools

0 commit comments

Comments
 (0)