-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a container image for the utility and build for it (#7)
PBENCH-1258
- Loading branch information
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |