Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add container build here #2

Merged
merged 9 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

name: Build Docker Container
on:
schedule:
- cron: '0 0 * * 1'
pull_request:
push:
branches:
- main


env:
REGISTRY: ghcr.io
BUILD_PLATFORMS: linux/amd64,linux/arm64
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# Ref: https://github.com/Zenika/alpine-chrome
chromium_version:
- 'latest'
- '89'
build_variant:
- ''
- 'with-chromedriver'
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.chromium_version }}

- name: Determine base image tag
id: container-base
run: |
#
# Setup base image tag as follows:
# - If the chromium_version is set to "latest" and build_variant is empty: use "latest"
# - If the chromium_version is set to "latest" and build_variant is specified: use build_variant
# - Otherwise: concatenate chromium_version and build_variant
#
# Ref: https://github.com/Zenika/alpine-chrome for image naming convention
#
if [[ "${{ matrix.chromium_version }}" == "latest" && "${{ matrix.build_variant }}" != "" ]]; then
build_tag="${{ matrix.build_variant }}"
elif [[ "${{ matrix.build_variant }}" == "" ]]; then
build_tag="${{ matrix.chromium_version }}"
else
build_tag="${{ matrix.chromium_version }}-${{ matrix.build_variant }}"
fi

echo "tag=${build_tag}" >> $GITHUB_OUTPUT

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
build-args: |
BASE_IMAGE_TAG=${{ steps.container-base.outputs.tag }}
platforms: ${{ env.BUILD_PLATFORMS }}
push: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM zenika/alpine-chrome:73
ARG BASE_IMAGE_TAG=latest
FROM zenika/alpine-chrome:${BASE_IMAGE_TAG}

LABEL maintainer="eiriksm <[email protected]>"
USER root
RUN mkdir -p mkdir /var/cache/apk && apk add --update chromium-chromedriver
ENTRYPOINT ["chromedriver", "--port=8643", "--url-base=wd/hub", "--headless", "--no-sandbox", "--whitelisted-ips="]
EXPOSE 8643
LABEL description="Chrome driver for selenium testing"

EXPOSE 8643
ENTRYPOINT ["chromedriver", "--allowed-ips=","--allowed-origins=*", "--port=8643", "--url-base=wd/hub", "--headless", "--no-sandbox", "--whitelisted-ips="]