From eb50299d03e009b03dc5e7f9fa4b02afff2f66ff Mon Sep 17 00:00:00 2001 From: Chris Coley <chris@codingallnight.com> Date: Sun, 20 Apr 2025 15:32:54 -0700 Subject: [PATCH] Refactor images for cleaner building and use --- .gitlab-ci.yml | 13 ++++++++----- Dockerfile | 20 +++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d91c6f..a8e5bd7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ stages: - release + .build: stage: build tags: [docker] @@ -13,10 +14,12 @@ stages: - >- /kaniko/executor --cache=false - --target "${BUILD_TARGET}" + --skip-unused-stages + --target ${BUILD_TARGET} --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-${BUILD_TARGET}" + --label org.opencontainers.image.authors="$LABEL_AUTHORS" --label org.opencontainers.image.created="$(date -u -Iseconds)" --label org.opencontainers.image.revision="$CI_COMMIT_SHA" --label org.opencontainers.image.source="$CI_PROJECT_URL" @@ -32,20 +35,22 @@ build:iperf3: BUILD_TARGET: iperf3 + .release: stage: release tags: [docker] image: name: gcr.io/go-containerregistry/crane:debug entrypoint: [''] + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH before_script: - - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - crane auth login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY" release:iperf2: extends: .release needs: ['build:iperf2'] script: - - crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-iperf2 2.2.0 - crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-iperf2 2.2 - crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-iperf2 2 @@ -53,9 +58,7 @@ release:iperf3: extends: .release needs: ['build:iperf3'] script: - - crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-iperf3 3.17.1 - crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-iperf3 3.17 - crane tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-iperf3 3 - # vi: set ts=2 sw=2 et ft=yaml: diff --git a/Dockerfile b/Dockerfile index ae405d8..9500be0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,16 @@ -FROM alpine:3.21 AS base -LABEL org.opencontainers.image.authors="Chris Coley <chris@codingallnight.com>" - # iPerf 2 image -FROM base AS iperf2 -ENV IPERF_VERSION="2.2.0-r0" -RUN apk add --no-cache iperf=${IPERF_VERSION} -ENTRYPOINT ["iperf", "-s"] +FROM alpine:3.21 AS iperf2 +RUN apk add --no-cache iperf=~2.2 +ENTRYPOINT ["iperf"] +CMD ["-s"] EXPOSE 5001/tcp 5001/udp + # iPerf 3 image -FROM base AS iperf3 -ENV IPERF_VERSION="3.17.1-r0" -RUN apk add --no-cache iperf3=${IPERF_VERSION} -ENTRYPOINT ["iperf3", "-s"] +FROM alpine:3.21 AS iperf3 +RUN apk add --no-cache iperf3=~3.17 +ENTRYPOINT ["iperf3"] +CMD ["-s"] EXPOSE 5201/tcp 5201/udp # vi: set ts=4 sw=4 et ft=dockerfile: -- GitLab