Skip to content

Commit

Permalink
build container images for workflows automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
skrobul committed Apr 2, 2024
1 parent 73dfb57 commit 18dabb6
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 12 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build-container-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: build-container-images

on:
pull_request:
paths:
- 'argo-workflows/generic/containers/*'
- 'argo-workflows/ironic-nautobot-sync/containers/*'
push:
branches:
- main
paths:
- 'argo-workflows/generic/containers/*'
- 'argo-workflows/ironic-nautobot-sync/containers/*'

jobs:
build-ghcr-registry:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to ghcr.io
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and deploy Python 3.11 image
uses: docker/build-push-action@v5
with:
context: argo-workflows/generic/
file: argo-workflows/generic/containers/Dockerfile.python311_alpine
# push for all main branch commits and manually triggered runs
# push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19:latest

- name: Build and deploy Python 3.12 image
uses: docker/build-push-action@v5
with:
context: argo-workflows/generic/
file: argo-workflows/generic/containers/Dockerfile.python311_alpine
# push for all main branch commits and manually triggered runs
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19:latest

- name: Build and deploy Python 3.11 with Ironic client
uses: docker/build-push-action@v5
with:
context: argo-workflows/generic/
file: argo-workflows/ironic-nautobot-sync/containers/Dockerfile.ironic
# push for all main branch commits and manually triggered runs
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/rackerlabs/understack/argo-ironic-client-python3.11.8
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM trow.sno.rackspace.net/f/docker/python:3.11.8-alpine3.19 as builder
FROM python:3.11.8-alpine3.19 as builder

LABEL org.opencontainers.image.title="Python 3.11 image base image"
LABEL org.opencontainers.image.base.name="registry.sno.rackspace.net/undercloud/argo-python3.11.8-alpine3.19"
LABEL org.opencontainers.image.base.name="ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19"
LABEL org.opencontainers.image.version="0.0.1"

ENV PYTHONUNBUFFERED=1
Expand Down Expand Up @@ -36,7 +36,7 @@ CMD ["python", "-"]
# RUN --mount=type=cache,target=/var/cache/apk apk add --virtual build-deps gcc python3-dev musl-dev linux-headers
# RUN --mount=type=cache,target=/root/.cache/.pip pip install --no-cache-dir python-ironicclient==5.4.0
#
# FROM trow.sno.rackspace.net/f/docker/python:3.11.8-alpine3.19 as prod
# FROM ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19 as prod
# ENV PATH="/opt/venv/bin:$PATH"
# COPY --from=builder /opt/venv /opt/venv
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM trow.sno.rackspace.net/f/docker/python:3.12.2-alpine3.19 as builder
FROM python:3.12.2-alpine3.19 as builder

LABEL org.opencontainers.image.title="Python 3.12 image base image"
LABEL org.opencontainers.image.base.name="registry.sno.rackspace.net/undercloud/argo-python3.12.2-alpine3.19"
LABEL org.opencontainers.image.base.name="ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19"
LABEL org.opencontainers.image.version="0.0.1"

ENV PYTHONUNBUFFERED=1
Expand All @@ -23,7 +23,7 @@ WORKDIR /app
CMD ["python", "-"]

# Example usage in final image
# FROM registry.sno.rackspace.net/undercloud/argo-python3.12.2-alpine3.19
# FROM ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19
#
# # This section needs to be repeated in child images
# ARG APP_PATH=/app
Expand All @@ -36,7 +36,7 @@ CMD ["python", "-"]
# RUN --mount=type=cache,target=/var/cache/apk apk add --virtual build-deps gcc python3-dev musl-dev linux-headers
# RUN --mount=type=cache,target=/root/.cache/.pip pip install --no-cache-dir python-ironicclient==5.4.0
#
# FROM trow.sno.rackspace.net/f/docker/python:3.12.2-alpine3.19 as prod
# FROM ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19 as prod
# ENV PATH="/opt/venv/bin:$PATH"
# COPY --from=builder /opt/venv /opt/venv
#
Expand Down
2 changes: 0 additions & 2 deletions argo-workflows/ironic-nautobot-sync/container/build_images.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE=registry.sno.rackspace.net/undercloud/argo-python3.11.8-alpine3.19:0.0.1
ARG BASE=ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19:latest

FROM ${BASE} as builder
RUN --mount=type=cache,target=/var/cache/apk apk add --virtual build-deps gcc python3-dev musl-dev linux-headers
Expand All @@ -11,7 +11,7 @@ ARG APP_GROUP=appgroup
ARG APP_USER_UID=1000
ARG APP_GROUP_GID=1000
LABEL org.opencontainers.image.title="Python 3.11 image with Ironic Client"
LABEL org.opencontainers.image.base.name="registry.sno.rackspace.net/undercloud/argo-ironic"
LABEL org.opencontainers.image.base.name="ghcr.io/rackerlabs/understack/argo-ironic-client-python3.11.8"
LABEL org.opencontainers.image.version="0.0.1"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
templates:
- name: synchronize-server
container:
image: registry.sno.rackspace.net/undercloud/argo-ironic:0.0.1
image: ghcr.io/rackerlabs/understack/argo-ironic-client-python3.11.8:latest
command:
- python
- /app/synchronize-server.py
Expand Down

0 comments on commit 18dabb6

Please sign in to comment.