diff --git a/.github/workflows/build-container-images.yaml b/.github/workflows/build-container-images.yaml new file mode 100644 index 000000000..9a8484ef4 --- /dev/null +++ b/.github/workflows/build-container-images.yaml @@ -0,0 +1,72 @@ +--- +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/*' + +# bump container versions here, they will be populated to tags and labels +env: + VERSION_PYTHON311: 0.0.1 + VERSION_PYTHON312: 0.0.1 + VERSION_PYTHON_IRONIC: 0.0.1 + +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 + push: ${{ github.event_name != 'pull_request' }} + tags: ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19:latest,ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19:{{ env.VERSION_PYTHON311 }} + labels: | + org.opencontainers.image.version: "{{ env.VERSION_PYTHON311 }}" + + - 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.python312_alpine + # push for all main branch commits + push: ${{ github.event_name != 'pull_request' }} + tags: ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19:latest,ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19:{{ env.VERSION_PYTHON312 }} + labels: | + org.opencontainers.image.version: "{{ env.VERSION_PYTHON312 }}" + + - name: Build and deploy Python 3.11 with Ironic client + uses: docker/build-push-action@v5 + with: + context: argo-workflows/ironic-nautobot-sync + file: argo-workflows/ironic-nautobot-sync/containers/Dockerfile.ironic + # push for all main branch commits + push: ${{ github.event_name != 'pull_request' }} + tags: ghcr.io/rackerlabs/understack/argo-ironic-client-python3.11.8:latest,ghcr.io/rackerlabs/understack/argo-ironic-client-python3.11.8:{{ env.VERSION_PYTHON_IRONIC }} + labels: | + org.opencontainers.image.version: "{{ env.VERSION_PYTHON_IRONIC }}" diff --git a/argo-workflows/example-feature/container/.gitkeep b/argo-workflows/example-feature/containers/.gitkeep similarity index 100% rename from argo-workflows/example-feature/container/.gitkeep rename to argo-workflows/example-feature/containers/.gitkeep diff --git a/argo-workflows/generic/Dockerfile.python311_alpine b/argo-workflows/generic/containers/Dockerfile.python311_alpine similarity index 78% rename from argo-workflows/generic/Dockerfile.python311_alpine rename to argo-workflows/generic/containers/Dockerfile.python311_alpine index 8b49a4166..0fc3ecfca 100644 --- a/argo-workflows/generic/Dockerfile.python311_alpine +++ b/argo-workflows/generic/containers/Dockerfile.python311_alpine @@ -1,8 +1,8 @@ -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.version="0.0.1" +LABEL org.opencontainers.image.base.name="ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19" +LABEL org.opencontainers.image.source=https://github.com/rackerlabs/understack ENV PYTHONUNBUFFERED=1 @@ -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 # diff --git a/argo-workflows/generic/Dockerfile.python312_alpine b/argo-workflows/generic/containers/Dockerfile.python312_alpine similarity index 73% rename from argo-workflows/generic/Dockerfile.python312_alpine rename to argo-workflows/generic/containers/Dockerfile.python312_alpine index 38e62f28b..4f511f054 100644 --- a/argo-workflows/generic/Dockerfile.python312_alpine +++ b/argo-workflows/generic/containers/Dockerfile.python312_alpine @@ -1,8 +1,8 @@ -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.version="0.0.1" +LABEL org.opencontainers.image.base.name="ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19" +LABEL org.opencontainers.image.source=https://github.com/rackerlabs/understack ENV PYTHONUNBUFFERED=1 @@ -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 @@ -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 # diff --git a/argo-workflows/ironic-nautobot-sync/container/build_images.sh b/argo-workflows/ironic-nautobot-sync/container/build_images.sh deleted file mode 100755 index 4bc3c6370..000000000 --- a/argo-workflows/ironic-nautobot-sync/container/build_images.sh +++ /dev/null @@ -1,2 +0,0 @@ -docker build -t registry.sno.rackspace.net/undercloud/argo-ironic:0.0.1 -f Dockerfile.ironic . -kind --name understack load docker-image registry.sno.rackspace.net/undercloud/argo-ironic:0.0.1 diff --git a/argo-workflows/ironic-nautobot-sync/container/Dockerfile.ironic b/argo-workflows/ironic-nautobot-sync/containers/Dockerfile.ironic similarity index 64% rename from argo-workflows/ironic-nautobot-sync/container/Dockerfile.ironic rename to argo-workflows/ironic-nautobot-sync/containers/Dockerfile.ironic index c34bc1169..8c3b1550d 100644 --- a/argo-workflows/ironic-nautobot-sync/container/Dockerfile.ironic +++ b/argo-workflows/ironic-nautobot-sync/containers/Dockerfile.ironic @@ -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 @@ -11,8 +11,8 @@ 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.version="0.0.1" +LABEL org.opencontainers.image.base.name="ghcr.io/rackerlabs/understack/argo-ironic-client-python3.11.8" +LABEL org.opencontainers.image.source=https://github.com/rackerlabs/understack ENV PATH="/opt/venv/bin:$PATH" @@ -22,5 +22,5 @@ WORKDIR /app USER $APP_USER -COPY --chown=${APP_USER}:${APP_GROUP} src/ /app +COPY --chown=${APP_USER}:${APP_GROUP} code/ /app CMD ["python", "/app/main.py"] diff --git a/argo-workflows/ironic-nautobot-sync/container/operate-workflow-sa-token.yaml b/argo-workflows/ironic-nautobot-sync/deps/operate-workflow-sa-token.yaml similarity index 100% rename from argo-workflows/ironic-nautobot-sync/container/operate-workflow-sa-token.yaml rename to argo-workflows/ironic-nautobot-sync/deps/operate-workflow-sa-token.yaml diff --git a/argo-workflows/ironic-nautobot-sync/workflowtemplates/synchronize-server-to-ironic.yaml b/argo-workflows/ironic-nautobot-sync/workflowtemplates/synchronize-server-to-ironic.yaml index ba552dc33..6d0b25e50 100644 --- a/argo-workflows/ironic-nautobot-sync/workflowtemplates/synchronize-server-to-ironic.yaml +++ b/argo-workflows/ironic-nautobot-sync/workflowtemplates/synchronize-server-to-ironic.yaml @@ -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