-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test docker image to ghcr for dynamic VM testing
- Loading branch information
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
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 | ||
id: get_changed_files | ||
run: | | ||
changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep ansible/docker/test/Dockerfile) | ||
echo "changed_files=$changed_files" >> "$GITHUB_OUTPUT" | ||
# Generate matrix | ||
- name: Generate matrix | ||
id: generate_matrix | ||
run: | | ||
matrix=$(jq -n --arg files "$changed_files" '{ | ||
include: ($files | split("\n") | map(select(length > 0) | {dockerfile: .})) | ||
}') | ||
echo "matrix=$matrix" >> "$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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |