Skip to content

Commit

Permalink
Add a container image for the utility and build for it (#7)
Browse files Browse the repository at this point in the history
PBENCH-1258
  • Loading branch information
webbnh authored Aug 30, 2023
1 parent b4784f8 commit c6492c6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Exclude everything but the listed exceptions.
*
!.git
!LICENSE
!pyproject.toml
!README.md
!src
!setup.*
61 changes: 61 additions & 0 deletions .github/workflows/container_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Create and publish a Docker image

# Configure this workflow to run every time a change is pushed to a branch
# whose name starts with `release/` or any time a tag is created; this workflow
# is also run any time a GitHub release is created or updated ("unpublish" and
# deletions do not cause it to run).
on:
push:
branches: ['release/**']
tags: ['*']
release:
types: [created, edited, prereleased, published, released]

# Set up the container image specification to be `quay.io/pbench/file-relay`.
env:
REGISTRY: quay.io
ORGANIZATION: pbench
IMAGE_NAME: file-relay

jobs:
build-and-push-image:
runs-on: ubuntu-latest

# Set the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_ROBOT_TOKEN }}

# Extract metadata from the Git reference and the GitHub event.
# Subsequent steps can reference the values via `steps.meta.outputs.<key>`.
# The `images` value provides the name for the container image which is
# used in tags and labels.
- name: Extract metadata (tags, labels) from Git for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}

# Build the container image based on the Dockerfile and the rest of the
# files found in the root of the Git checkout. If the build succeeds,
# the image is pushed to the registry indicated by the tags.
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
network: host
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.9
LABEL org.opencontainers.image.authors="Pbench Maintainers <[email protected]>"

ENTRYPOINT ["relay"]
WORKDIR /var/tmp

# Make sure the packaging and installation tools are up to date.
RUN python3 -m pip install --upgrade pip setuptools wheel

# Copy the files from the context area to a source directory; install the
# dependencies and the app; and remove the sources.
COPY . /src/file-relay
RUN python3 -m pip install -r /src/file-relay/src/requirements.txt /src/file-relay
RUN rm -rf /src/file-relay

0 comments on commit c6492c6

Please sign in to comment.