-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New project structure and build scripts (#11)
* new structure * add --all to help message * Adds better info message. * Adds comment to use of ARG in Dockerfiles * Adds a prefix to image tag name * add 17 * Xshare dump for 11 * Create docker.yml * add GH Action flow
- Loading branch information
1 parent
a1883a3
commit 7b77a75
Showing
12 changed files
with
130 additions
and
144 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,25 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: Docker Images CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
jdk_version: [8, 11, 17] | ||
linux_distro: [cbld, mariner, ubuntu] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Runs a single command using the runners shell | ||
- name: Build the image | ||
run: ./build.sh ${{ linux_distro }} ${{ jdk_version }} |
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,78 @@ | ||
#!/bin/bash | ||
|
||
jdkversions=(`cat jdk_versions | grep -v "# *" | grep -v "^$"`) | ||
distros=(`ls -1 docker/`) | ||
image_prefix="mcr.microsoft.com/openjdk/jdk" | ||
|
||
help() { | ||
cat << EOF | ||
Microsoft Build of OpenJDK - Docker Image Builder | ||
Copyright (c) 2021, Microsoft Corporation | ||
$ build.sh [--all] | [distro] [version] | ||
Arguments: | ||
--all: builds all base images and JDK versions defined in './jdk_versions' | ||
[distro]: the base image to build | ||
Any of: ${distros[*]} | ||
[version]: the JDK version to use | ||
Any of: ${jdkversions[*]} | ||
EOF | ||
exit 0 | ||
} | ||
|
||
# Builds the image with tag '$jdk-$distro' | ||
build_image() { | ||
_distro=$1 | ||
_jdk=$2 | ||
|
||
docker build \ | ||
--build-arg JDK_VERSION=$_jdk \ | ||
-f docker/$_distro/Dockerfile \ | ||
-t $image_prefix:$_jdk-$_distro docker/$_distro | ||
} | ||
|
||
build_all() { | ||
echo "Building all distro images and JDK versions." | ||
for d in ${distros[*]}; do | ||
for j in ${jdkversions[*]}; do | ||
build_image $d $j | ||
done | ||
done | ||
exit 0 | ||
} | ||
|
||
build_single() { | ||
# Check if distro argument is valid | ||
if [[ ! ${distros[*]} =~ "$1" ]]; then | ||
echo "Base image '${1}' not available." | ||
exit 1 | ||
fi | ||
|
||
# Check if jdk version argument is valid | ||
if [[ ! ${jdkversions[*]} =~ "$2" ]]; then | ||
echo "JDK version '${2}' not available." | ||
exit 1 | ||
fi | ||
|
||
# Build a single image | ||
echo "Building single image 'distro=${1} jdk=${2}' ..." | ||
build_image $1 $2 | ||
} | ||
|
||
# Check if needs to print help | ||
if [[ "$#" -eq 0 ]] || [[ "$#" -gt "2" ]]; then help; fi | ||
|
||
# Check if user wants to build all. Otherwise builds one, or show help message. | ||
if [[ "$#" -eq 1 ]] && [[ '--all' == "$1" ]]; then | ||
build_all | ||
elif [[ "$#" -eq 1 ]]; then | ||
echo "Invalid argument: '${1}'" | ||
exit 1 | ||
elif [ "$#" -eq 2 ]; then | ||
build_single $1 $2 | ||
else | ||
help | ||
fi |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
# One major JDK version per line | ||
11 | ||
16 | ||
17 |