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

add test docker image to ghcr for dynamic VM testing #3775

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
74 changes: 74 additions & 0 deletions .github/workflows/build_test_containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Docker

on:
pull_request:
paths:
- .github/workflows/build_test_containers.yml
- ansible/docker/test/Dockerfile*
branches:
- master
push:
paths:
- .github/workflows/build_test_containers.yml
- ansible/docker/test/Dockerfile*
branches:
- master

permissions:
contents: read
packages: write

jobs:
generate-matrix:
name: Generate Matrix
runs-on: ubuntu-latest
if: github.repository_owner == 'adoptium'
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

# Get list of changed files in ansible/docker/test/Dockerfile*
- name: Get list of changed Dockerfiles
run: |
if [ ${{ github.event_name }} == "push" ]; then
changed_files=$(git diff --name-only HEAD~1 | grep ansible/docker/test/Dockerfile || true)
else
changed_files=$(git diff --name-only origin/master | grep ansible/docker/test/Dockerfile || true)
fi
echo $changed_files
echo "changed_files=$changed_files" >> "$GITHUB_ENV"

# Generate matrix
- name: Generate matrix
if: ${{ env.changed_files != '' }}
id: generate_matrix
run: |
matrix=$(jq -n --arg files "${changed_files}" '{
"include": ($files | split("\n") | map(select(length > 0) | {dockerfile: .}))
}')
echo "matrix<<EOF"$'\n'"$matrix"$'\n'EOF >> $GITHUB_OUTPUT

build-dockerfiles:
name: Build Dockerfiles
runs-on: ubuntu-latest
needs: generate-matrix
strategy:
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

# Generate tag name based on the Dockerfile name
- name: Set tag name
run: echo "TAG_NAME=$(basename ${{ matrix.dockerfile }} | cut -d'.' -f2 | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Build Dockerfile
run: docker build -t ghcr.io/${{ github.repository_owner }}/test-containers:$TAG_NAME -f ${{ matrix.dockerfile }} .

- name: Push Dockerfile to ghcr.io
if: github.event_name == 'push'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
docker push ghcr.io/${{ github.repository_owner }}/test-containers:$TAG_NAME
43 changes: 43 additions & 0 deletions ansible/docker/test/Dockerfile.Ubuntu2204
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ubuntu:22.04

ARG ant_version="1.10.15"
ARG ant_512checksum="1de7facbc9874fa4e5a2f045d5c659f64e0b89318c1dbc8acc6aae4595c4ffaf90a7b1ffb57f958dd08d6e086d3fff07aa90e50c77342a0aa5c9b4c36bff03a9"
ARG user="jenkins"

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -qq -y \
curl \
fontconfig \
gcc \
git \
gnupg \
libxi6 \
libxrender1 \
libxtst6 \
locales \
make \
openjdk-17-jdk-headless \
openssh-client \
perl \
unzip \
wget \
xvfb \
zip

# Install ant
RUN wget -q -O /tmp/ant.zip "https://archive.apache.org/dist/ant/binaries/apache-ant-${ant_version}-bin.zip"
RUN wget -q -O /tmp/ant-contrib.tar.gz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.tar.gz
RUN echo "$ant_512checksum /tmp/ant.zip" > /tmp/ant.sha512
RUN echo "0fd2771dca2b8b014a4cb3246715b32e20ad5d26754186d82eee781507a183d5e63064890b95eb27c091c93c1209528a0b18a6d7e6901899319492a7610e74ad /tmp/ant-contrib.tar.gz" >> /tmp/ant.sha512
RUN sha512sum --check --strict /tmp/ant.sha512
RUN ln -s /usr/local/apache-ant-${ant_version}/bin/ant /usr/bin/ant
RUN unzip -q -d /usr/local /tmp/ant.zip
RUN tar xpfz /tmp/ant-contrib.tar.gz -C /usr/local/apache-ant-${ant_version}/lib --strip-components=2 ant-contrib/lib/ant-contrib.jar

# Clear up space
RUN rm /tmp/ant.zip /tmp/ant-contrib.tar.gz

RUN locale-gen en_US.utf8

RUN groupadd -g 1000 ${user}
RUN useradd -c "Jenkins user" -d /home/${user} -u 1000 -g 1000 -m ${user}