Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Poetry in build scripts and CI #24

Merged
merged 3 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
tags:
- "*"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
release:
name: release
Expand All @@ -20,11 +24,38 @@ jobs:
- name: Install release dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install poetry==1.1.7

- name: Build and publish package
env:
TWINE_USERNAME: ${{ secrets.PYPI_STACUTILS_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_STACUTILS_PASSWORD }}
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_STACUTILS_USERNAME }}
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_STACUTILS_PASSWORD }}
run: |
scripts/cipublish

- name: Tag Release
uses: "marvinpinto/action-automatic-releases@v1.2.1"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
32 changes: 25 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ ENV POSTGIS_MAJOR 3
ENV PGUSER postgres
ENV PGDATABASE postgres
ENV PGHOST localhost
ENV \
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_NO_INTERACTION=1

RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
# curl \
gnupg \
apt-transport-https \
debian-archive-keyring \
# jq \
software-properties-common \
postgresql-$PG_MAJOR-pgtap \
postgresql-$PG_MAJOR-partman \
Expand All @@ -24,19 +31,30 @@ RUN \
python3 \
python3-pip \
python3-setuptools \
# git \
&& pip3 install -U pip setuptools packaging \
&& pip3 install -U psycopg2-binary \
&& pip3 install -U migra[pg] \
&& apt-get remove -y apt-transport-https software-properties-common build-essential python3-pip python3-dev python3-setuptools \
&& pip3 install poetry==1.1.7 \
&& apt-get remove -y apt-transport-https \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*

EXPOSE 5432

RUN mkdir -p /docker-entrypoint-initdb.d
# COPY ./docker/initpgstac.sh /docker-entrypoint-initdb.d/initpgstac.sh
# COPY ./pgstac.sql /workspaces/pgstac.sql
COPY ./sql /docker-entrypoint-initdb.d/

WORKDIR /workspaces
RUN mkdir -p /opt/src/pypgstac

WORKDIR /opt/src/pypgstac

COPY pypgstac/poetry.lock pypgstac/pyproject.toml ./
RUN poetry install


COPY pypgstac /opt/src/pypgstac
RUN poetry install

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

WORKDIR /opt/src
25 changes: 19 additions & 6 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
FROM python:3.8-slim
FROM python:3.8-slim as python-base

ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
ENV \
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_NO_INTERACTION=1

RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

RUN pip install poetry==1.1.7

RUN mkdir -p /opt/src/pypgstac

WORKDIR /opt/src/pypgstac

COPY pypgstac/requirements-dev.txt /opt/src/pypgstac/requirements-dev.txt
RUN pip install -r requirements-dev.txt
COPY pypgstac/poetry.lock pypgstac/pyproject.toml ./
RUN poetry install


COPY pypgstac /opt/src/pypgstac
RUN pip install .
RUN poetry install

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

WORKDIR /opt/src
WORKDIR /opt/src
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
- POSTGRES_DB=postgis
- PGUSER=username
- PGPASSWORD=password
- PGHOST=localhost
- PGDATABASE=postgis
ports:
- "5432:5432"
Expand Down
Loading