Skip to content

Commit 020fcb2

Browse files
committed
Workflow to make docker release images.
1 parent 69e46ab commit 020fcb2

File tree

2 files changed

+88
-3
lines changed

2 files changed

+88
-3
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
---
12
name: test and push docker images
23

34
on:
45
push:
56
branches: [main]
7+
tags:
8+
- '*'
69

710
jobs:
811
test:
@@ -27,11 +30,11 @@ jobs:
2730
runs-on: ubuntu-latest
2831
steps:
2932
- name: Checkout
30-
uses: actions/checkout@v2
33+
uses: actions/checkout@v3
3134
- name: Set up QEMU
32-
uses: docker/setup-qemu-action@v1
35+
uses: docker/setup-qemu-action@v2
3336
- name: Set up Docker Buildx
34-
uses: docker/setup-buildx-action@v1
37+
uses: docker/setup-buildx-action@v2
3538
- name: Cache Docker layers
3639
uses: actions/cache@v3
3740
with:
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
name: push docker release images
3+
4+
on:
5+
push:
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Install Python 3
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: 3.8
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install .
22+
docker:
23+
needs: build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
- name: Set up QEMU
29+
uses: docker/setup-qemu-action@v2
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v2
32+
- name: Cache Docker layers
33+
uses: actions/cache@v3
34+
with:
35+
path: /tmp/.buildx-cache
36+
key: ${{ runner.os }}-buildx-${{ github.sha }}
37+
restore-keys: |
38+
${{ runner.os }}-buildx-
39+
- name: Login to DockerHub
40+
uses: docker/login-action@v2
41+
with:
42+
username: ${{ secrets.DOCKERHUB_USERNAME }}
43+
password: ${{ secrets.DOCKERHUB_TOKEN }}
44+
- name: Build and push
45+
id: docker_build
46+
uses: docker/build-push-action@v3
47+
with:
48+
push: true
49+
tags: mihxil/npo-pyapi:${GITHUB_REF##*/}
50+
context: .
51+
file: docker/Dockerfile
52+
cache-from: type=local,src=/tmp/.buildx-cache
53+
cache-to: type=local,dest=/tmp/.buildx-cache-new
54+
- name: Build and push flask
55+
id: docker_build_flask
56+
uses: docker/build-push-action@v3
57+
with:
58+
push: true
59+
tags: mihxil/npo-pyapi-flask:${GITHUB_REF##*/}
60+
context: flask
61+
cache-from: type=local,src=/tmp/.buildx-cache
62+
cache-to: type=local,dest=/tmp/.buildx-cache-new
63+
- name: Build and push make
64+
id: docker_build_make
65+
uses: docker/build-push-action@v3
66+
with:
67+
push: true
68+
tags: mihxil/npo-pyapi-make:${GITHUB_REF##*/}
69+
context: docker/make
70+
cache-from: type=local,src=/tmp/.buildx-cache
71+
cache-to: type=local,dest=/tmp/.buildx-cache-new
72+
- name: Image digest
73+
run: echo ${{ steps.docker_build.outputs.digest }}
74+
# This ugly bit is necessary if you don't want your cache to grow forever
75+
# till it hits GitHub's limit of 5GB.
76+
# Temp fix
77+
# https://github.com/docker/build-push-action/issues/252
78+
# https://github.com/moby/buildkit/issues/1896
79+
- name: Move cache
80+
run: |
81+
rm -rf /tmp/.buildx-cache
82+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 commit comments

Comments
 (0)