Skip to content

Commit d89589e

Browse files
authored
Use Poetry in build scripts and CI (#24)
* Use poetry * Add Github Action to push to github docker registry on when adding a tag
1 parent 0598b36 commit d89589e

File tree

9 files changed

+466
-97
lines changed

9 files changed

+466
-97
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- "*"
77

8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
812
jobs:
913
release:
1014
name: release
@@ -20,11 +24,38 @@ jobs:
2024
- name: Install release dependencies
2125
run: |
2226
python -m pip install --upgrade pip
23-
pip install setuptools wheel twine
27+
pip install poetry==1.1.7
2428
2529
- name: Build and publish package
2630
env:
27-
TWINE_USERNAME: ${{ secrets.PYPI_STACUTILS_USERNAME }}
28-
TWINE_PASSWORD: ${{ secrets.PYPI_STACUTILS_PASSWORD }}
31+
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_STACUTILS_USERNAME }}
32+
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_STACUTILS_PASSWORD }}
2933
run: |
3034
scripts/cipublish
35+
36+
- name: Tag Release
37+
uses: "marvinpinto/[email protected]"
38+
with:
39+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
40+
prerelease: false
41+
42+
- name: Log in to the Container registry
43+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
44+
with:
45+
registry: ${{ env.REGISTRY }}
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Extract metadata (tags, labels) for Docker
50+
id: meta
51+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
52+
with:
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
55+
- name: Build and push Docker image
56+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
57+
with:
58+
context: .
59+
push: true
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ ENV POSTGIS_MAJOR 3
66
ENV PGUSER postgres
77
ENV PGDATABASE postgres
88
ENV PGHOST localhost
9+
ENV \
10+
PYTHONUNBUFFERED=1 \
11+
PYTHONFAULTHANDLER=1 \
12+
PYTHONDONTWRITEBYTECODE=1 \
13+
PIP_NO_CACHE_DIR=off \
14+
PIP_DISABLE_PIP_VERSION_CHECK=on \
15+
PIP_DEFAULT_TIMEOUT=100 \
16+
POETRY_VIRTUALENVS_CREATE=false \
17+
POETRY_NO_INTERACTION=1
918

1019
RUN \
1120
apt-get update \
1221
&& apt-get install -y --no-install-recommends \
13-
# curl \
1422
gnupg \
1523
apt-transport-https \
1624
debian-archive-keyring \
17-
# jq \
1825
software-properties-common \
1926
postgresql-$PG_MAJOR-pgtap \
2027
postgresql-$PG_MAJOR-partman \
@@ -24,19 +31,30 @@ RUN \
2431
python3 \
2532
python3-pip \
2633
python3-setuptools \
27-
# git \
2834
&& pip3 install -U pip setuptools packaging \
2935
&& pip3 install -U psycopg2-binary \
3036
&& pip3 install -U migra[pg] \
31-
&& apt-get remove -y apt-transport-https software-properties-common build-essential python3-pip python3-dev python3-setuptools \
37+
&& pip3 install poetry==1.1.7 \
38+
&& apt-get remove -y apt-transport-https \
3239
&& apt-get -y autoremove \
3340
&& rm -rf /var/lib/apt/lists/*
3441

3542
EXPOSE 5432
3643

3744
RUN mkdir -p /docker-entrypoint-initdb.d
38-
# COPY ./docker/initpgstac.sh /docker-entrypoint-initdb.d/initpgstac.sh
39-
# COPY ./pgstac.sql /workspaces/pgstac.sql
4045
COPY ./sql /docker-entrypoint-initdb.d/
4146

42-
WORKDIR /workspaces
47+
RUN mkdir -p /opt/src/pypgstac
48+
49+
WORKDIR /opt/src/pypgstac
50+
51+
COPY pypgstac/poetry.lock pypgstac/pyproject.toml ./
52+
RUN poetry install
53+
54+
55+
COPY pypgstac /opt/src/pypgstac
56+
RUN poetry install
57+
58+
ENV PYTHONPATH=/opt/src/pypgstac:${PYTHONPATH}
59+
60+
WORKDIR /opt/src

Dockerfile.dev

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1-
FROM python:3.8-slim
1+
FROM python:3.8-slim as python-base
22

3-
ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
3+
ENV \
4+
PYTHONUNBUFFERED=1 \
5+
PYTHONFAULTHANDLER=1 \
6+
PYTHONDONTWRITEBYTECODE=1 \
7+
PIP_NO_CACHE_DIR=off \
8+
PIP_DISABLE_PIP_VERSION_CHECK=on \
9+
PIP_DEFAULT_TIMEOUT=100 \
10+
POETRY_VIRTUALENVS_CREATE=false \
11+
POETRY_NO_INTERACTION=1
12+
13+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
14+
15+
RUN pip install poetry==1.1.7
416

517
RUN mkdir -p /opt/src/pypgstac
618

719
WORKDIR /opt/src/pypgstac
820

9-
COPY pypgstac/requirements-dev.txt /opt/src/pypgstac/requirements-dev.txt
10-
RUN pip install -r requirements-dev.txt
21+
COPY pypgstac/poetry.lock pypgstac/pyproject.toml ./
22+
RUN poetry install
23+
1124

1225
COPY pypgstac /opt/src/pypgstac
13-
RUN pip install .
26+
RUN poetry install
1427

1528
ENV PYTHONPATH=/opt/src/pypgstac:${PYTHONPATH}
1629

17-
WORKDIR /opt/src
30+
WORKDIR /opt/src

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ services:
2626
- POSTGRES_DB=postgis
2727
- PGUSER=username
2828
- PGPASSWORD=password
29+
- PGHOST=localhost
2930
- PGDATABASE=postgis
3031
ports:
3132
- "5432:5432"

0 commit comments

Comments
 (0)