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

New project structure and build scripts (#11) #19

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/docker.yml
@@ -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 }}
78 changes: 78 additions & 0 deletions build.sh
@@ -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
Expand Up @@ -4,23 +4,27 @@ MAINTAINER Microsoft OpenJDK Support <openjdk-support@microsoft.com>
LABEL "Author"="Microsoft"
LABEL "Support"="Microsoft OpenJDK Support <openjdk-support@microsoft.com>"

# Defaults to 17 so this Dockerfile is always buildable.
# Valid values are listed in 'jdk_versions' file.
ARG JDK_VERSION=17

RUN DEBIAN_FRONTEND=noninteractive && \
apt-get -qq update && \
apt-get -qq upgrade && \
apt-get -qq install --no-install-recommends tzdata ca-certificates fontconfig locales apt-transport-https wget && \
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
locale-gen en_US.UTF-8 && \
rm -rf /var/lib/apt/lists/* && \
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
echo "deb https://packages.microsoft.com/repos/cbl-d quinault-universe main" >> /etc/apt/sources.list && \
apt-get -qq update && \
apt-get -qq install msopenjdk-11 && \
apt-get -qq install msopenjdk-$JDK_VERSION && \
apt-get -qq purge apt-transport-https && \
apt-get -qq autoremove --purge && \
rm -rf /var/lib/apt/lists/* && \
echo java -Xshare:dump && \
java -Xshare:dump
if [ "$JDK_VERSION" = "11" ]; then java -Xshare:dump; fi

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

ENV JAVA_HOME=/usr/lib/jvm/msopenjdk-11-amd64
ENV JAVA_HOME=/usr/lib/jvm/msopenjdk-$JDK_VERSION-amd64
25 changes: 0 additions & 25 deletions docker/cbld/Dockerfile.msopenjdk-16-jdk

This file was deleted.

25 changes: 0 additions & 25 deletions docker/cbld/Dockerfile.msopenjdk-17-jdk

This file was deleted.

Expand Up @@ -4,6 +4,10 @@ MAINTAINER Microsoft OpenJDK Support <openjdk-support@microsoft.com>
LABEL "Author"="Microsoft"
LABEL "Support"="Microsoft OpenJDK Support <openjdk-support@microsoft.com>"

# Defaults to 17 so this Dockerfile is always buildable.
# Valid values are listed in 'jdk_versions' file.
ARG JDK_VERSION=17

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

RUN tdnf -y update && \
Expand All @@ -12,6 +16,7 @@ RUN tdnf -y update && \
rm -rf /var/cache/tdnf && \
rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm && \
tdnf install -y mariner-repos-ui && \
tdnf install -y msopenjdk-16 --nogpgcheck
tdnf install -y msopenjdk-$JDK_VERSION --nogpgcheck && \
if [ "$JDK_VERSION" = "11" ]; then java -Xshare:dump; fi

ENV JAVA_HOME=/usr/lib/jvm/msopenjdk-16
ENV JAVA_HOME=/usr/lib/jvm/msopenjdk-$JDK_VERSION
19 changes: 0 additions & 19 deletions docker/mariner/Dockerfile.msopenjdk-11-jdk

This file was deleted.

17 changes: 0 additions & 17 deletions docker/mariner/Dockerfile.msopenjdk-17-jdk

This file was deleted.

@@ -1,5 +1,9 @@
FROM ubuntu:focal

# Defaults to 17 so this Dockerfile is always buildable.
# Valid values are listed in 'jdk_versions' file.
ARG JDK_VERSION=17

MAINTAINER Microsoft OpenJDK Support <openjdk-support@microsoft.com>
LABEL "Author"="Microsoft"
LABEL "Support"="Microsoft OpenJDK Support <openjdk-support@microsoft.com>"
Expand All @@ -14,11 +18,12 @@ RUN DEBIAN_FRONTEND=noninteractive && \
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
apt-get -qq update && \
apt-get -qq install msopenjdk-16 && \
apt-get -qq install msopenjdk-$JDK_VERSION && \
apt-get -qq purge apt-transport-https wget && \
apt-get -qq autoremove --purge && \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* && \
if [ "$JDK_VERSION" = "11" ]; then java -Xshare:dump; fi

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

ENV JAVA_HOME=/usr/lib/jvm/msopenjdk-16-amd64
ENV JAVA_HOME=/usr/lib/jvm/msopenjdk-$JDK_VERSION-amd64
25 changes: 0 additions & 25 deletions docker/ubuntu/Dockerfile.msopenjdk-11-jdk

This file was deleted.

24 changes: 0 additions & 24 deletions docker/ubuntu/Dockerfile.msopenjdk-17-jdk

This file was deleted.

4 changes: 4 additions & 0 deletions jdk_versions
@@ -0,0 +1,4 @@
# One major JDK version per line
11
16
17