Skip to content

Commit 2ca2ef9

Browse files
xrmxv1v
andauthored
ci: use elastic registry only if available (#228)
ci: use elastic registry only if available The elastic docker registry is not available for forks of this repo or to dependabot so if you cannot use it use alternative upstream docker images. Co-authored-by: Victor Martinez <[email protected]>
1 parent 6d6b827 commit 2ca2ef9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.github/workflows/ci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040
- run: pip-licenses
4141

4242
operator-image-buildable:
43+
env:
44+
USE_ELASTIC_REGISTRY: ${{ github.event_name != 'pull_request' || ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && github.actor != 'dependabot[bot]' ) }}
4345
runs-on: ubuntu-latest
4446
steps:
4547
- uses: actions/checkout@v4
@@ -54,7 +56,11 @@ jobs:
5456
registry: ${{ secrets.ELASTIC_DOCKER_REGISTRY }}
5557
username: ${{ secrets.ELASTIC_DOCKER_USERNAME }}
5658
password: ${{ secrets.ELASTIC_DOCKER_PASSWORD }}
59+
if: ${{ env.USE_ELASTIC_REGISTRY == 'true' }}
5760
- run: docker build -f operator/Dockerfile --build-arg DISTRO_DIR=./dist .
61+
if: ${{ env.USE_ELASTIC_REGISTRY == 'true' }}
62+
- run: docker build -f operator/Dockerfile --build-arg PYTHON_GLIBC_IMAGE=cgr.dev/chainguard/python --build-arg PYTHON_GLIBC_IMAGE_VERSION=latest-dev --build-arg DISTRO_DIR=./dist --build-arg IMAGE=cgr.dev/chainguard/bash --build-arg IMAGE_VERSION=latest .
63+
if: ${{ env.USE_ELASTIC_REGISTRY != 'true'}}
5864

5965
test:
6066
runs-on: ubuntu-latest

operator/Dockerfile

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
FROM docker.elastic.co/wolfi/python:3.12-dev@sha256:2f10787cc037b197f6a5d1a031c31706ae59642708c8b3b5ddfd3fa79605e9ad AS build
1+
ARG PYTHON_GLIBC_IMAGE="docker.elastic.co/wolfi/python"
2+
ARG PYTHON_GLIBC_IMAGE_VERSION="3.12-dev@sha256:2f10787cc037b197f6a5d1a031c31706ae59642708c8b3b5ddfd3fa79605e9ad"
3+
4+
ARG IMAGE="docker.elastic.co/wolfi/chainguard-base"
5+
ARG IMAGE_VERSION="latest@sha256:26caa6beaee2bbf739a82e91a35173892dfe888d0a744b9e46cdc19a90d8656f"
6+
7+
FROM ${PYTHON_GLIBC_IMAGE}:${PYTHON_GLIBC_IMAGE_VERSION} AS build
28

39
ENV LANG=C.UTF-8
410
ENV PYTHONDONTWRITEBYTECODE=1
@@ -32,7 +38,7 @@ RUN apk add gcc g++ python3-dev musl-dev linux-headers
3238

3339
RUN pip install --no-cache-dir --target workspace /opt/distro/*.whl -r requirements.txt
3440

35-
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:26caa6beaee2bbf739a82e91a35173892dfe888d0a744b9e46cdc19a90d8656f
41+
FROM ${IMAGE}:${IMAGE_VERSION}
3642

3743
COPY --from=build /operator-build/workspace /autoinstrumentation
3844
COPY --from=build-musl /operator-build/workspace /autoinstrumentation-musl

0 commit comments

Comments
 (0)