From 867f23fb58f3e7430a961440699e0510185930f1 Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 5 Mar 2022 10:20:07 +0200 Subject: [PATCH] Use local Docker registry in GitHub Action The tests container copies files from the build containers. In order for this to work in the GitHub actions workflow, the build images need to be uploaded to a local Docker registry first. --- .github/workflows/build-and-test.yml | 26 +++++++++++++++++++------- tests/Dockerfile | 10 ++++++++-- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1fd0d9b..8b13b0a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -9,36 +9,48 @@ jobs: build-and-test: name: Build curl-impersonate and run the tests runs-on: ubuntu-latest + services: + # A local registry is needed to push the build images to because we use + # the 'docker-container' driver. See + # https://github.com/docker/buildx/issues/301 + # and + # See https://github.com/docker/build-push-action/blob/master/docs/advanced/local-registry.md + registry: + image: registry:2 + ports: + - 5000:5000 steps: - name: Check out the repo uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + driver-opts: network=host - name: Build the Chrome version of curl-impersonate uses: docker/build-push-action@v2 with: - push: false - load: true + push: true context: chrome/ - tags: curl-impersonate-chrome:latest + tags: localhost:5000/curl-impersonate/chrome - name: Build the Firefox version of curl-impersonate uses: docker/build-push-action@v2 with: - push: false - load: true + push: true context: firefox/ - tags: curl-impersonate-firefox:latest + tags: localhost:5000/curl-impersonate/ff - name: Build the tests container uses: docker/build-push-action@v2 with: - push: false load: true context: tests/ tags: curl-impersonate-tests:latest + build-args: | + FIREFOX_IMAGE=localhost:5000/curl-impersonate/ff + CHROME_IMAGE=localhost:5000/curl-impersonate/chrome - name: Run the tests run: docker run --rm curl-impersonate-tests --log-cli-level DEBUG diff --git a/tests/Dockerfile b/tests/Dockerfile index 741d0b5..28d5595 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,3 +1,9 @@ +ARG FIREFOX_IMAGE=curl-impersonate-ff +ARG CHROME_IMAGE=curl-impersonate-chrome + +FROM ${FIREFOX_IMAGE} as ff +FROM ${CHROME_IMAGE} as chrome + FROM python:3.10.1-slim-buster WORKDIR /tests @@ -13,8 +19,8 @@ RUN pip install --upgrade pip && \ RUN mkdir /tests/firefox /tests/chrome # Copy the built binaries from both containers -COPY --from=curl-impersonate-ff /build/out/* /tests/firefox/ -COPY --from=curl-impersonate-chrome /build/out/* /tests/chrome/ +COPY --from=ff /build/out/* /tests/firefox/ +COPY --from=chrome /build/out/* /tests/chrome/ COPY . .