-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
83 additions
and
40 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 |
---|---|---|
@@ -1,61 +1,89 @@ | ||
name: Build and publish image to ghcr.io/epics-containers | ||
name: Build and publish image to ghcr.io/epics-containers | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
build: | ||
# pull requests are a duplicate of a branch push if within the same repo. | ||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository | ||
permissions: | ||
contents: read | ||
packages: write | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
epics-target: [linux-x86_64] # , linux-aarch64] | ||
include: | ||
- os: ubuntu-latest # everyone is on ubuntu-latest | ||
- epics-target: linux-x86_64 | ||
platform: linux/amd64 | ||
|
||
# # a temporary name until multi-arch is supported | ||
# - epics-target: linux-aarch64 | ||
# extension: -native-aarch64 | ||
# platform: linux/arm64 | ||
|
||
runs-on: ${{ matrix.os }} | ||
env: | ||
TAG: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Determine container image tag to use | ||
id: tag | ||
run: | | ||
# tag is branch name or tag if there is a tag | ||
echo ::set-output name=image_tag::${GITHUB_REF##*/} | ||
echo ::set-output name=do_push::true | ||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
|
||
- name: Log in to GitHub Docker Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io/epics-containers | ||
registry: ghcr.io/${{ github.repository_owner }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build developer image | ||
uses: docker/build-push-action@v5 | ||
- name: Build image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
platforms: ${{ matrix.platform }} | ||
target: final | ||
cache-from: type=gha,scope=${{ matrix.epics-target }} | ||
cache-to: type=gha,mode=max,scope=${{ matrix.epics-target }} | ||
tags: ci_test | ||
load: true | ||
|
||
- name: Test image | ||
# Opportunity to run tests using docker run 'ci_test' | ||
if: ${{ matrix.epics-target == 'linux-x86_64' }} | ||
run: if [ -f tests/run-tests.sh ]; then tests/run-tests.sh ci_test; fi | ||
|
||
- name: Push runtime image | ||
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | ||
uses: docker/build-push-action@v6 | ||
with: | ||
platforms: ${{ matrix.platform }} | ||
target: runtime | ||
tags: ${{ env.TAG }}:${{ github.ref_name }} | ||
push: true | ||
|
||
- name: Push debug image | ||
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | ||
uses: docker/build-push-action@v6 | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
push: ${{ steps.tag.outputs.do_push }} | ||
tags: | | ||
ghcr.io/${{ github.repository }}:latest | ||
ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.image_tag }} | ||
# - name: Build runtime image | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# builder: ${{ steps.buildx.outputs.name }} | ||
# push: ${{ steps.tag.outputs.do_push }} | ||
# tags: | | ||
# ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.image_tag }}.run | ||
# target: runtime | ||
# cache-from: type=local,src=/tmp/.buildx-cache | ||
# cache-to: type=local,dest=/tmp/.buildx-cache | ||
platforms: ${{ matrix.platform }} | ||
target: dockerizer | ||
tags: ${{ env.TAG }}-debug:${{ github.ref_name }} | ||
push: true | ||
|
||
release: | ||
# Release on tag push | ||
needs: [build] | ||
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Github Release | ||
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 | ||
with: | ||
generate_release_notes: true |
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 |
---|---|---|
@@ -1,9 +1,24 @@ | ||
FROM python:3.11 | ||
FROM python:3.11-slim as common | ||
|
||
ENV PATH=/venv/bin:$PATH | ||
|
||
FROM python:3.11 as install | ||
|
||
RUN python -mvenv /venv | ||
ENV PATH=/venv/bin:$PATH | ||
|
||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
|
||
FROM common as debug | ||
|
||
RUN apt update && apt install -y net-tools tcpdump iproute2 iputils-ping vim | ||
COPY --from=install /venv /venv | ||
|
||
ENTRYPOINT [ "bash" ] | ||
|
||
FROM common as runtime | ||
|
||
COPY --from=install /venv /venv | ||
|
||
ENTRYPOINT [ "bash" ] |