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.
This commit is contained in:
lwthiker
2022-03-05 10:20:07 +02:00
parent f6554b909e
commit 867f23fb58
2 changed files with 27 additions and 9 deletions

View File

@@ -9,36 +9,48 @@ jobs:
build-and-test: build-and-test:
name: Build curl-impersonate and run the tests name: Build curl-impersonate and run the tests
runs-on: ubuntu-latest 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: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Build the Chrome version of curl-impersonate - name: Build the Chrome version of curl-impersonate
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
push: false push: true
load: true
context: chrome/ context: chrome/
tags: curl-impersonate-chrome:latest tags: localhost:5000/curl-impersonate/chrome
- name: Build the Firefox version of curl-impersonate - name: Build the Firefox version of curl-impersonate
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
push: false push: true
load: true
context: firefox/ context: firefox/
tags: curl-impersonate-firefox:latest tags: localhost:5000/curl-impersonate/ff
- name: Build the tests container - name: Build the tests container
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
push: false
load: true load: true
context: tests/ context: tests/
tags: curl-impersonate-tests:latest 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 - name: Run the tests
run: docker run --rm curl-impersonate-tests --log-cli-level DEBUG run: docker run --rm curl-impersonate-tests --log-cli-level DEBUG

View File

@@ -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 FROM python:3.10.1-slim-buster
WORKDIR /tests WORKDIR /tests
@@ -13,8 +19,8 @@ RUN pip install --upgrade pip && \
RUN mkdir /tests/firefox /tests/chrome RUN mkdir /tests/firefox /tests/chrome
# Copy the built binaries from both containers # Copy the built binaries from both containers
COPY --from=curl-impersonate-ff /build/out/* /tests/firefox/ COPY --from=ff /build/out/* /tests/firefox/
COPY --from=curl-impersonate-chrome /build/out/* /tests/chrome/ COPY --from=chrome /build/out/* /tests/chrome/
COPY . . COPY . .