Merge pull request #114 from vexxhost/image-builds
chore: cleanup image builds
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 39f1e15..5ca0154 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,67 +1,40 @@
name: build
+
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
+
on:
workflow_dispatch:
- inputs:
- image_push:
- type: boolean
- description: 'Push images to Container Registry'
- required: false
- default: false
- pull_request:
- types:
- - opened
- - synchronize
- - reopened
push:
branches:
- - main
+ - 'main'
+ tags:
+ - 'v*'
+ pull_request:
+ branches:
+ - 'main'
+
jobs:
image:
runs-on: ubuntu-latest
- strategy:
- matrix:
- from:
- - jammy
- release:
- - "2023.1"
steps:
- - name: Install QEMU static binaries
- uses: docker/setup-qemu-action@v2
- - name: Configure Buildkit
- uses: docker/setup-buildx-action@v2
- - name: Checkout project
- uses: actions/checkout@v3
- - name: Setup environment variables
- run: echo "PROJECT_REF=${{ github.sha }}" >> "$GITHUB_ENV"
- - name: Authenticate with Quay.io
- uses: docker/login-action@v2
- if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.image_push == true) }}
+ - uses: docker/setup-qemu-action@v3
+ - uses: docker/setup-buildx-action@v3
+ - uses: actions/checkout@v4
+ - uses: docker/metadata-action@v5
+ id: meta
with:
- password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- registry: quay.io
- username: ${{ secrets.QUAY_USERNAME }}
- - name: Build image
- uses: docker/build-push-action@v3
+ images: ghcr.io/vexxhost/staffeln
+ - uses: docker/login-action@v3
+ if: github.event_name != 'pull_request'
with:
- build-args: |-
- BUILDER_IMAGE=quay.io/vexxhost/openstack-builder-${{ matrix.from }}
- RUNTIME_IMAGE=quay.io/vexxhost/openstack-runtime-${{ matrix.from }}
- RELEASE=${{ matrix.release }}
- PROJECT=staffln
- PROJECT_REPO=https://github.com/vexxhost/staffeln
- PROJECT_REF=${{ env.PROJECT_REF }}
- cache-from: type=gha,scope=${{ matrix.from }}-${{ matrix.release }}
- cache-to: type=gha,mode=max,scope=${{ matrix.from }}-${{ matrix.release }}
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - uses: docker/build-push-action@v5
+ with:
context: .
- platforms: linux/amd64
- push: ${{ github.event_name == 'push' || inputs.image_push == true }}
- tags: quay.io/vexxhost/staffeln:${{ env.PROJECT_REF }}-${{ matrix.from }}
- - name: Promote image
- uses: akhilerm/tag-push-action@v2.0.0
- if: github.event_name == 'push' && ((matrix.from == 'focal') || (matrix.from == 'jammy' && matrix.release != 'yoga'))
- with:
- dst: quay.io/vexxhost/staffeln:${{ matrix.release }}
- src: quay.io/vexxhost/staffeln:${{ env.PROJECT_REF }}-${{ matrix.from }}
+ push: ${{ github.event_name != 'pull_request' }}
+ labels: ${{ steps.meta.outputs.labels }}
+ tags: ${{ steps.meta.outputs.tags }}
diff --git a/Dockerfile b/Dockerfile
index b21c967..59f0e97 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,18 +1,12 @@
-# syntax=docker/dockerfile-upstream:master-labs
+# syntax=docker/dockerfile:1.5
-ARG BUILDER_IMAGE=quay.io/vexxhost/openstack-builder-focal
-ARG RUNTIME_IMAGE=quay.io/vexxhost/openstack-runtime-focal
+FROM python:3.10 AS builder
+RUN python3 -m venv /venv
+ENV PATH=/venv/bin:$PATH
+ADD . /src
+RUN --mount=type=cache,target=/root/.cache \
+ pip install /src
-# hadolint ignore=DL3007
-FROM quay.io/vexxhost/bindep-loci:latest AS bindep
-
-FROM ${BUILDER_IMAGE}:ced4522d9a10ba7172f373289af6dace06be3b36 AS builder
-COPY --from=bindep --link /runtime-pip-packages /runtime-pip-packages
-
-FROM ${RUNTIME_IMAGE}:a391e31bb33041611e2aa2797debcb21e6f221cd AS runtime
-COPY --from=bindep --link /runtime-dist-packages /runtime-dist-packages
-COPY --from=builder --link /var/lib/openstack /var/lib/openstack
-# hadolint ignore=DL3022
-COPY --from=docker.io/alpine/helm:3.11.2 /usr/bin/helm /usr/local/bin/helm
-# hadolint ignore=DL3022
-COPY --from=gcr.io/go-containerregistry/crane /ko-app/crane /usr/local/bin/crane
+FROM python:3.10-slim AS runtime
+ENV PATH=/venv/bin:$PATH
+COPY --from=builder /venv /venv