Skip to content

Commit d0de622

Browse files
authored
Merge pull request #340 from geopython/Dockerfile
add Docker support
2 parents 515a3f1 + 223d87f commit d0de622

3 files changed

Lines changed: 152 additions & 0 deletions

File tree

.github/workflows/containers.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: Publish Docker image
7+
8+
on:
9+
workflow_run:
10+
workflows: ["Build"]
11+
types: [completed]
12+
branches: [master]
13+
push:
14+
tags:
15+
- '[0-9]+.[0-9]+.[0-9]+'
16+
17+
env:
18+
DOCKER_REPOSITORY: ${{ secrets.DOCKER_REPOSITORY || 'geopython/pygeometa' }}
19+
20+
jobs:
21+
on-success:
22+
name: Build, Test and Push Docker Image to DockerHub
23+
runs-on: ubuntu-24.04
24+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
25+
permissions:
26+
packages: write
27+
contents: read
28+
steps:
29+
- name: Check out the repo
30+
uses: actions/checkout@master
31+
32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v2.1.0
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v2.2.1
37+
38+
- name: Log in to Docker Hub
39+
uses: docker/login-action@v2.1.0
40+
with:
41+
username: ${{ secrets.DOCKER_USERNAME }}
42+
password: ${{ secrets.DOCKER_PASSWORD }}
43+
44+
- name: Log in to the Container registry
45+
uses: docker/login-action@v2.1.0
46+
with:
47+
registry: ghcr.io
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Extract metadata (tags, labels) for Docker
52+
id: meta
53+
uses: docker/metadata-action@v4.0.1
54+
with:
55+
images: |
56+
${{ env.DOCKER_REPOSITORY }}
57+
ghcr.io/${{ github.repository }}
58+
tags: |
59+
type=semver,pattern={{version}}
60+
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
61+
62+
- name: Build and push Docker images
63+
uses: docker/build-push-action@v3.3.0
64+
with:
65+
context: .
66+
push: true
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
cache-from: type=gha
70+
cache-to: type=gha,mode=max
71+
platforms: linux/arm64, linux/amd64
72+
73+
on-failure:
74+
runs-on: ubuntu-24.04
75+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
76+
steps:
77+
- name: Print Test Fail
78+
run: echo Tests Failed

Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# =================================================================
2+
#
3+
# Terms and Conditions of Use
4+
#
5+
# Unless otherwise noted, computer program source code of this
6+
# distribution # is covered under Crown Copyright, Government of
7+
# Canada, and is distributed under the MIT License.
8+
#
9+
# The Canada wordmark and related graphics associated with this
10+
# distribution are protected under trademark law and copyright law.
11+
# No permission is granted to use them outside the parameters of
12+
# the Government of Canada's corporate identity program. For
13+
# more information, see
14+
# http://www.tbs-sct.gc.ca/fip-pcim/index-eng.asp
15+
#
16+
# Copyright title to all 3rd party software distributed with this
17+
# software is held by the respective copyright holders as noted in
18+
# those files. Users are asked to read the 3rd Party Licenses
19+
# referenced with those assets.
20+
#
21+
# Copyright (c) 2026 Tom Kralidis
22+
#
23+
# Permission is hereby granted, free of charge, to any person
24+
# obtaining a copy of this software and associated documentation
25+
# files (the "Software"), to deal in the Software without
26+
# restriction, including without limitation the rights to use,
27+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
28+
# copies of the Software, and to permit persons to whom the
29+
# Software is furnished to do so, subject to the following
30+
# conditions:
31+
#
32+
# The above copyright notice and this permission notice shall be
33+
# included in all copies or substantial portions of the Software.
34+
#
35+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
37+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
39+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
40+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
41+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
42+
# OTHER DEALINGS IN THE SOFTWARE.
43+
#
44+
# =================================================================
45+
46+
FROM python:3.14-slim
47+
48+
ENV PYTHONDONTWRITEBYTECODE=1 \
49+
PYTHONUNBUFFERED=1
50+
51+
RUN useradd -m pygeometa
52+
53+
WORKDIR /app
54+
COPY ./ /app
55+
56+
RUN python3.14 -m venv --system-site-packages /venv && \
57+
/venv/bin/pip3 install .
58+
59+
USER pygeometa
60+
61+
62+
ENTRYPOINT ["/venv/bin/pygeometa"]

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[![Build Status](https://github.com/geopython/pygeometa/workflows/build%20%E2%9A%99%EF%B8%8F/badge.svg)](https://github.com/geopython/pygeometa/actions)
22
[![Join the chat at https://matrix.to/#/#geopython_pygeometa:gitter.im](https://badges.gitter.im/Join%20Chat.svg)](https://matrix.to/#/#geopython_pygeometa:gitter.im)
3+
[![Docker](https://github.com/geopython/pygeometa/actions/workflows/containers.yml/badge.svg)](https://github.com/geopython/pygeometa/actions/workflows/containers.yml)
4+
[![Vulnerabilities](https://github.com/geopython/pygeometa/actions/workflows/vulnerabilities.yml/badge.svg)](https://github.com/geopython/pygeometa/actions/workflows/vulnerabilities.yml)
35

46
# pygeometa
57

@@ -73,6 +75,16 @@ pygeometa metadata transform path/to/file.xml --input-schema=iso19139 --output-s
7375
pygeometa metadata transform path/to/file.xml --input-schema=autodetect --output-schema=oarec-record # --input-schema=autodetect is default
7476
```
7577

78+
## Docker
79+
80+
pygeometa can also be run as a Docker application:
81+
82+
```bash
83+
# run pygeometa via Docker, and map local path /path/to/my-data-dir to /data in Docker
84+
docker run -ti -v /path/to/my-data-dir/:/data/ pygeometa:latest metadata generate --schema oarec-record /data/sample.mcf.yml
85+
```
86+
87+
7688
### Supported schemas
7789
Schemas supported by pygeometa:
7890
* CSV on the web, [reference](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/)

0 commit comments

Comments
 (0)