Skip to content

Commit c6492c6

Browse files
authored
Add a container image for the utility and build for it (#7)
PBENCH-1258
1 parent b4784f8 commit c6492c6

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Exclude everything but the listed exceptions.
2+
*
3+
!.git
4+
!LICENSE
5+
!pyproject.toml
6+
!README.md
7+
!src
8+
!setup.*
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Create and publish a Docker image
2+
3+
# Configure this workflow to run every time a change is pushed to a branch
4+
# whose name starts with `release/` or any time a tag is created; this workflow
5+
# is also run any time a GitHub release is created or updated ("unpublish" and
6+
# deletions do not cause it to run).
7+
on:
8+
push:
9+
branches: ['release/**']
10+
tags: ['*']
11+
release:
12+
types: [created, edited, prereleased, published, released]
13+
14+
# Set up the container image specification to be `quay.io/pbench/file-relay`.
15+
env:
16+
REGISTRY: quay.io
17+
ORGANIZATION: pbench
18+
IMAGE_NAME: file-relay
19+
20+
jobs:
21+
build-and-push-image:
22+
runs-on: ubuntu-latest
23+
24+
# Set the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
25+
permissions:
26+
contents: read
27+
packages: write
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v3
32+
33+
- name: Log in to the Container registry
34+
uses: docker/login-action@v2
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ secrets.REGISTRY_USERNAME }}
38+
password: ${{ secrets.REGISTRY_ROBOT_TOKEN }}
39+
40+
# Extract metadata from the Git reference and the GitHub event.
41+
# Subsequent steps can reference the values via `steps.meta.outputs.<key>`.
42+
# The `images` value provides the name for the container image which is
43+
# used in tags and labels.
44+
- name: Extract metadata (tags, labels) from Git for Docker
45+
id: meta
46+
uses: docker/metadata-action@v4
47+
with:
48+
images: ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}
49+
50+
# Build the container image based on the Dockerfile and the rest of the
51+
# files found in the root of the Git checkout. If the build succeeds,
52+
# the image is pushed to the registry indicated by the tags.
53+
- name: Build and push Docker image
54+
uses: docker/build-push-action@v4
55+
with:
56+
context: .
57+
file: Dockerfile
58+
network: host
59+
push: true
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:3.9
2+
LABEL org.opencontainers.image.authors="Pbench Maintainers <[email protected]>"
3+
4+
ENTRYPOINT ["relay"]
5+
WORKDIR /var/tmp
6+
7+
# Make sure the packaging and installation tools are up to date.
8+
RUN python3 -m pip install --upgrade pip setuptools wheel
9+
10+
# Copy the files from the context area to a source directory; install the
11+
# dependencies and the app; and remove the sources.
12+
COPY . /src/file-relay
13+
RUN python3 -m pip install -r /src/file-relay/src/requirements.txt /src/file-relay
14+
RUN rm -rf /src/file-relay

0 commit comments

Comments
 (0)