Skip to content

Commit 6cf56b4

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

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep ansible/docker/test/Dockerfile)
38+
echo "changed_files=$changed_files" >> "$GITHUB_OUTPUT"
39+
40+
# Generate matrix
41+
- name: Generate matrix
42+
id: generate_matrix
43+
run: |
44+
matrix=$(jq -n --arg files "$changed_files" '{
45+
include: ($files | split("\n") | map(select(length > 0) | {dockerfile: .}))
46+
}')
47+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
48+
49+
build-dockerfiles:
50+
name: Build Dockerfiles
51+
runs-on: ubuntu-latest
52+
needs: generate-matrix
53+
strategy:
54+
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
55+
steps:
56+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
57+
58+
# Generate tag name based on the Dockerfile name
59+
- name: Set tag name
60+
run: echo "TAG_NAME=$(basename ${{ matrix.dockerfile }} | cut -d'.' -f2 | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
61+
62+
- name: Build Dockerfile
63+
run: docker build -t ghcr.io/${{ github.repository_owner }}/test-containers:$TAG_NAME -f ${{ matrix.dockerfile }} .
64+
65+
- name: Push Dockerfile to ghcr.io
66+
if: github.event_name == 'push'
67+
run: |
68+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
69+
docker push ghcr.io/${{ github.repository_owner }}/test-containers:$TAG_NAME
+43
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)