Skip to content

Commit f8bce71

Browse files
committed
feat: Adding docker build
1 parent 2ca5431 commit f8bce71

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

.github/workflows/build.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
merge_group:
6+
push:
7+
branches:
8+
- develop
9+
tags:
10+
- '*'
11+
12+
jobs:
13+
Build:
14+
name: Build and Test on ${{ matrix.python }} and ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: ['macos-latest', 'ubuntu-latest']
19+
python: ['pypy3.9', 'pypy3.10', '3.9', '3.10', '3.11']
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python }}
27+
28+
- name: Install dependencies
29+
id: install-deps
30+
run: |
31+
pip3 install -r requirements.txt
32+
33+
- name: Write version vars
34+
id: version-vars
35+
run: |
36+
BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
37+
BRANCH=${GITHUB_REF_NAME#v}
38+
APP_VERSION=$(cat config.json | grep version| head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g')
39+
echo Version: $APP_VERSION
40+
echo "VERSION=$APP_VERSION" >> $GITHUB_ENV
41+
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
42+
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
43+
44+
Container:
45+
name: Build Container Image
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Build image
50+
id: build-image
51+
uses: redhat-actions/buildah-build@v2
52+
with:
53+
image: cloudtooling/data-anonymizer
54+
tags: 'latest next ${{env.APP_VERSION}} ${{env.APP_VERSION}}_rc'
55+
containerfiles: |
56+
./Dockerfile
57+
build-args: |
58+
BUILD_DATE=${{env.BUILD_DATE}}
59+
APP_VERSION=${{env.APP_VERSION}}
60+
61+
- name: Push To Docker Hub
62+
id: push-to-dockerhub-preview
63+
uses: redhat-actions/push-to-registry@v2
64+
with:
65+
image: ${{ steps.build-image.outputs.image }}
66+
tags: 'next ${{env.APP_VERSION}}_rc'
67+
registry: registry.hub.docker.com
68+
username: ${{ secrets.DOCKER_HUB_USER}}
69+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
70+
if: github.ref == 'refs/heads/develop'
71+
72+
- name: Push To Docker Hub
73+
id: push-to-dockerhub-tagged
74+
uses: redhat-actions/push-to-registry@v2
75+
with:
76+
image: ${{ steps.build-image.outputs.image }}
77+
tags: 'latest ${{env.APP_VERSION}}'
78+
registry: registry.hub.docker.com
79+
username: ${{ secrets.DOCKER_HUB_USER}}
80+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
81+
if: github.ref_type == 'tag' || github.tag != ''
82+
83+
Build-results:
84+
name: Build results
85+
if: ${{ always() }}
86+
runs-on: ubuntu-latest
87+
needs:
88+
- Build
89+
- Container
90+
steps:
91+
- run: exit 1
92+
# see https://stackoverflow.com/a/67532120/4907315
93+
if: >-
94+
${{
95+
contains(needs.*.result, 'failure')
96+
|| contains(needs.*.result, 'cancelled')
97+
|| contains(needs.*.result, 'skipped')
98+
}}

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:3.9
2+
3+
ARG BUILD_DATE
4+
ARG APP_VERSION
5+
6+
LABEL org.opencontainers.image.authors='Martin Reinhardt (martin@m13t.de)' \
7+
org.opencontainers.image.created=$BUILD_DATE \
8+
org.opencontainers.image.version=$APP_VERSION \
9+
org.opencontainers.image.url='https://hub.docker.com/r/hypery2k/varta-exporter' \
10+
org.opencontainers.image.documentation='https://github.com/hypery2k/varta-exporterr' \
11+
org.opencontainers.image.source='https://github.com/hypery2k/varta-exporterr.git' \
12+
org.opencontainers.image.licenses='MIT'
13+
14+
RUN apt-get -f install libxml2-dev libxslt-dev zlib1g-dev gcc
15+
16+
COPY . .
17+
RUN pip install -r requirements.txt
18+
19+
ENTRYPOINT ["python3", "multi_anonymizer.py"]

config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"version": "0.1.0"
3+
}

0 commit comments

Comments
 (0)