Skip to content

Commit

Permalink
Add automated Docker image builds
Browse files Browse the repository at this point in the history
* Removed redundant `setup.py` file. `pip install`, for example, will
  prefer the pyproject.toml file, and we didn't notice that file exists,
  so we were confused for too long about why our changes to `setup.py`
  were not "registering".
* Add pdgstaging dependency to `pyproject.toml`

Co-Authored-By: Rushiraj Nenuji <[email protected]>
  • Loading branch information
mfisher87 and rushirajnenuji committed May 30, 2024
1 parent fbfa06d commit 977ff86
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 41 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Build and publish container image"

on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "[0-9]+.[0-9]+.[0-9]+*"


env:
REGISTRY: "ghcr.io"
IMAGE_NAME: "${{ github.repository_owner }}/pdgraster"
IMAGE_TAG: "${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}"


jobs:

build-and-release-image:
name: "Build and release container image"
runs-on: "ubuntu-latest"

permissions:
packages: "write"
attestations: "write"

steps:
- name: "Check out repository"
uses: "actions/checkout@v3"

- name: "Build container image"
run: |
docker build --tag "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}" .
- name: "GHCR login"
uses: "docker/login-action@v2"
with:
registry: "${{ env.REGISTRY }}"
username: "${{ github.repository_owner }}"
password: "${{ secrets.GITHUB_TOKEN }}"

- name: "Push to GHCR"
run: |
docker push "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.10-slim

# Install transitive dependencies
RUN apt-get update \
&& apt-get install -y git libspatialindex-dev libgdal-dev libproj-dev

# Add source
WORKDIR /app
ADD . .

# Install pdgraster from source
RUN pip install .

CMD ["python"]
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "pdgraster"
version = "0.9.2"
description = "Geospatial data rasterization workflow"
description = "Rasterization to GeoTiff and web-based tiles for the PDG Visualization pipeline"
authors = [
"Robyn Thiessen-Bock <[email protected]>",
"Juliet Cohen <[email protected]>",
Expand Down Expand Up @@ -32,6 +32,7 @@ colormaps = "== 0.4.0"
Pillow = ">= 9, < 10"
rasterio = ">= 1.2, < 2"
pydantic = "1.10.9"
pdgstaging = { git="https://github.com/PermafrostDiscoveryGateway/viz-staging.git" }

[tool.poetry.group.dev.dependencies]
pytest = ">=7"
Expand Down
40 changes: 0 additions & 40 deletions setup.py

This file was deleted.

0 comments on commit 977ff86

Please sign in to comment.