Skip to content

Commit e61933d

Browse files
author
Igor Živković
authored
Merge pull request #3 from LeoQuote/master
add docker build and push workflow
2 parents f2115dc + d2a6665 commit e61933d

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
push:
10+
branches: [ master ]
11+
# Publish semver tags as releases.
12+
tags: [ 'v*.*.*' ]
13+
pull_request:
14+
branches: [ master ]
15+
16+
env:
17+
# Use docker.io for Docker Hub if empty
18+
REGISTRY: ghcr.io
19+
# github.repository as <account>/<repo>
20+
IMAGE_NAME: ${{ github.repository }}
21+
22+
23+
jobs:
24+
build:
25+
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v2
34+
35+
# Login against a Docker registry except on PR
36+
# https://github.com/docker/login-action
37+
- name: Log into registry ${{ env.REGISTRY }}
38+
if: github.event_name != 'pull_request'
39+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
# Extract metadata (tags, labels) for Docker
46+
# https://github.com/docker/metadata-action
47+
- name: Extract Docker metadata
48+
id: meta
49+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
50+
with:
51+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52+
53+
# Build and push Docker image with Buildx (don't push on PR)
54+
# https://github.com/docker/build-push-action
55+
- name: Build and push Docker image
56+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
57+
with:
58+
context: .
59+
push: ${{ github.event_name != 'pull_request' }}
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM library/python:3.8
2+
3+
COPY requirements.txt requirements.txt
4+
5+
RUN pip install -r requirements.txt
6+
7+
COPY tinyproxy_exporter tinyproxy_exporter
8+
9+
ENTRYPOINT ["python", "tinyproxy_exporter"]

0 commit comments

Comments
 (0)