Skip to content

Commit 0f129d1

Browse files
committed
add test docker image to ghcr for dynamic VM testing
1 parent 6edae3d commit 0f129d1

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Docker
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/build_test_containers.yml
7+
- ansible/docker/test/Dockerfile*
8+
branches:
9+
- master
10+
push:
11+
paths:
12+
- .github/workflows/build_test_containers.yml
13+
- ansible/docker/test/Dockerfile*
14+
branches:
15+
- master
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
jobs:
22+
generate-matrix:
23+
name: Generate Matrix
24+
runs-on: ubuntu-latest
25+
if: github.repository_owner == 'adoptium'
26+
outputs:
27+
matrix: ${{ steps.generate_matrix.outputs.matrix }}
28+
steps:
29+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
30+
with:
31+
fetch-depth: 0
32+
33+
# Get list of changed files in ansible/docker/test/Dockerfile*
34+
- name: Get list of changed Dockerfiles
35+
id: get_changed_files
36+
run: |
37+
if [ ${{ github.event_name }} == "push" ]; then
38+
changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep ansible/docker/test/Dockerfile)
39+
else
40+
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep ansible/docker/test/Dockerfile)
41+
fi
42+
echo "changed_files=$changed_files" >> "$GITHUB_OUTPUT"
43+
44+
# Generate matrix
45+
- name: Generate matrix
46+
id: generate_matrix
47+
run: |
48+
matrix=$(jq -n --arg files "$changed_files" '{
49+
include: ($files | split("\n") | map(select(length > 0) | {dockerfile: .}))
50+
}')
51+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
52+
53+
build-dockerfiles:
54+
name: Build Dockerfiles
55+
runs-on: ubuntu-latest
56+
needs: generate-matrix
57+
strategy:
58+
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
59+
steps:
60+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
61+
62+
# Generate tag name based on the Dockerfile name
63+
- name: Set tag name
64+
run: echo "TAG_NAME=$(basename ${{ matrix.dockerfile }} | cut -d'.' -f2 | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
65+
66+
- name: Build Dockerfile
67+
run: docker build -t ghcr.io/${{ github.repository_owner }}/test-containers:$TAG_NAME -f ${{ matrix.dockerfile }} .
68+
69+
- name: Push Dockerfile to ghcr.io
70+
if: github.event_name == 'push'
71+
run: |
72+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
73+
docker push ghcr.io/${{ github.repository_owner }}/test-containers:$TAG_NAME
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM ubuntu:22.04
2+
3+
ARG ant_version="1.10.15"
4+
ARG ant_512checksum="1de7facbc9874fa4e5a2f045d5c659f64e0b89318c1dbc8acc6aae4595c4ffaf90a7b1ffb57f958dd08d6e086d3fff07aa90e50c77342a0aa5c9b4c36bff03a9"
5+
ARG user="jenkins"
6+
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
RUN apt-get update && apt-get install -qq -y \
9+
curl \
10+
fontconfig \
11+
gcc \
12+
git \
13+
gnupg \
14+
libxi6 \
15+
libxrender1 \
16+
libxtst6 \
17+
locales \
18+
make \
19+
openjdk-17-jdk-headless \
20+
openssh-client \
21+
perl \
22+
unzip \
23+
wget \
24+
xvfb \
25+
zip
26+
27+
# Install ant
28+
RUN wget -q -O /tmp/ant.zip "https://archive.apache.org/dist/ant/binaries/apache-ant-${ant_version}-bin.zip"
29+
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
30+
RUN echo "$ant_512checksum /tmp/ant.zip" > /tmp/ant.sha512
31+
RUN echo "0fd2771dca2b8b014a4cb3246715b32e20ad5d26754186d82eee781507a183d5e63064890b95eb27c091c93c1209528a0b18a6d7e6901899319492a7610e74ad /tmp/ant-contrib.tar.gz" >> /tmp/ant.sha512
32+
RUN sha512sum --check --strict /tmp/ant.sha512
33+
RUN ln -s /usr/local/apache-ant-${ant_version}/bin/ant /usr/bin/ant
34+
RUN unzip -q -d /usr/local /tmp/ant.zip
35+
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
36+
37+
# Clear up space
38+
RUN rm /tmp/ant.zip /tmp/ant-contrib.tar.gz
39+
40+
RUN locale-gen en_US.utf8
41+
42+
RUN groupadd -g 1000 ${user}
43+
RUN useradd -c "Jenkins user" -d /home/${user} -u 1000 -g 1000 -m ${user}

0 commit comments

Comments
 (0)