Skip to content

Commit

Permalink
Attempt to build and automate container creation
Browse files Browse the repository at this point in the history
This is based on the Dockerfile provided at #284 with some
tweaks.

Makefile is adjusted to allow easy experimentation, but the
primary work here uses github actions.
  • Loading branch information
cdent committed Nov 26, 2021
1 parent 8fbd547 commit abb762e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: docker

#on:
# release:
# types: [published]

on: [push]


jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: cdent/gabbi
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- 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 }}
build-args:
GABBI_VERSION=${{steps.meta.outputs.version}}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3-alpine
MAINTAINER Chris Dent <cdent@anticdent.org>

ARG GABBI_VERSION
RUN python -m venv /app
COPY . /app/
RUN cd /app && PBR_VERSION=${GABBI_VERSION} /app/bin/pip --no-cache-dir install .

ENTRYPOINT ["/app/bin/python", "-m", "gabbi.runner"]
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# simple Makefile for some common tasks
.PHONY: clean test dist release pypi tagv docs

gabbi-version := $(shell python -c 'import gabbi; print gabbi.__version__')

clean:
find . -name "*.pyc" |xargs rm || true
rm -r dist || true
Expand All @@ -12,9 +14,7 @@ clean:
rm -r gabbi.egg-info || true

tagv:
git tag -s \
-m `python -c 'import gabbi; print gabbi.__version__'` \
`python -c 'import gabbi; print gabbi.__version__'`
git tag -s -m ${gabbi-version} ${gabbi-version}
git push origin main --tags

cleanagain:
Expand All @@ -41,3 +41,6 @@ release: clean test cleanagain tagv pypi
pypi:
python3 setup.py sdist bdist_wheel
twine upload -s dist/*

docker:
docker build --build-arg GABBI_VERSION=${gabbi-version} -t gabbi:${gabbi-version} .

0 comments on commit abb762e

Please sign in to comment.