Skip to content

Commit ebb9b42

Browse files
authored
feat: docker build workflow (#308)
feat: build and publish container image
1 parent 3af7ff8 commit ebb9b42

File tree

5 files changed

+110
-10
lines changed

5 files changed

+110
-10
lines changed
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build & Publish Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
permissions:
11+
packages: write
12+
contents: read
13+
14+
env:
15+
IMAGE_NAME: ${{ github.repository }}
16+
REGISTRY: ghcr.io
17+
18+
jobs:
19+
build:
20+
timeout-minutes: 15
21+
runs-on: ubuntu-22.04
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
26+
- name: Generate Docker Metadata
27+
id: meta
28+
uses: docker/metadata-action@v4
29+
with:
30+
github-token: ${{ secrets.GITHUB_TOKEN }}
31+
images: |
32+
ghcr.io/${{ github.actor }}/${{ github.repository }}
33+
tags: |
34+
type=schedule
35+
type=ref,event=branch
36+
type=ref,event=pr
37+
type=semver,pattern={{version}}
38+
type=semver,pattern={{major}}.{{minor}}
39+
type=semver,pattern={{major}}
40+
type=sha
41+
42+
- name: Set up QEMU To support build amd64 and arm64 images
43+
uses: docker/setup-qemu-action@v2
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v2
47+
48+
- name: Login to the Github Container Registry
49+
uses: docker/login-action@v2
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Build and push
56+
uses: docker/build-push-action@v3
57+
id: docker_build
58+
with:
59+
push: ${{ github.event_name != 'pull_request' && ( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' ) }}
60+
context: .
61+
platforms: linux/amd64,linux/arm64
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max
66+
67+
- name: Output image, digest and metadata to summary
68+
run: |
69+
{
70+
echo imageid: "${{ steps.docker_build.outputs.imageid }}"
71+
echo digest: "${{ steps.docker_build.outputs.digest }}"
72+
echo labels: "${{ steps.meta.outputs.labels }}"
73+
echo tags: "${{ steps.meta.outputs.tags }}"
74+
echo version: "${{ steps.meta.outputs.version }}"
75+
} >> "$GITHUB_STEP_SUMMARY"

.github/workflows/python-app.yml renamed to .github/workflows/build-test.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# This workflow will install Python dependencies, run tests and lint with a single version of Python
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python application
4+
name: Build and Test Python Package
55

66
on:
7+
workflow_dispatch:
78
push:
89
branches: [ "master" ]
910
pull_request:
@@ -14,9 +15,7 @@ permissions:
1415

1516
jobs:
1617
build:
17-
1818
runs-on: ubuntu-latest
19-
2019
steps:
2120
- uses: actions/checkout@v3
2221
- uses: actions/setup-python@v3

.github/workflows/lint-docker.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Lint Dockerfile"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "**/Dockerfile.*"
7+
- "**/docker-compose.*"
8+
branches:
9+
- main
10+
- master
11+
workflow_dispatch:
12+
13+
jobs:
14+
hadolint:
15+
name: "Lint Docker with hadolint"
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
19+
- name: run tflint
20+
uses: reviewdog/action-hadolint@master
21+
with:
22+
github_token: ${{ secrets.github_token }}
23+
reporter: github-pr-review
24+
fail_on_error: "false"
25+
level: warning
26+
filter_mode: "nofilter" # Optional. Check all files, not just the diff

Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
FROM python:2.7
22

3-
MAINTAINER Simon Toivo Telhaug <[email protected]>
4-
53
RUN apt-get update \
6-
&& apt-get install man-db -y
4+
&& apt-get install man-db -y \
5+
&& apt-get clean
76

87
ADD ./requirements.txt /tmp/requirements.txt
98

109
RUN pip install --upgrade pip \
11-
&& python --version \
12-
&& pip install -r /tmp/requirements.txt
10+
&& python --version \
11+
&& pip install -r /tmp/requirements.txt \
12+
&& rm -rf ~/.cache/pip/*
1313

1414
ADD ./ /opt/webapp/
1515
WORKDIR /opt/webapp

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [explainshell.com](http://www.explainshell.com) - match command-line arguments to their help text
1+
# [explainshell.com](http://www.explainshell.com) - match command-line arguments to their help text
22

33
explainshell is a tool (with a web interface) capable of parsing man pages, extracting options and
44
explain a given command-line by matching each argument to the relevant help text in the man page.
@@ -72,7 +72,7 @@ INFO:explainshell.store:inserting mapping (alias) echo -> echo (52207a1fa9b52e42
7272
successfully added echo
7373
```
7474

75-
### Start up a local web server:
75+
### Start up a local web server
7676

7777
```ShellSession
7878
$ make serve

0 commit comments

Comments
 (0)