forked from meissa/ModeratorElection
[skip ci]Refactoring in Docker image building, see also section dockerizing in doc/dev_notes.md to handle one Dockerfile for different builds
This commit is contained in:
parent
38edbbfb94
commit
ae34bec4df
2 changed files with 62 additions and 43 deletions
|
@ -1,24 +1,39 @@
|
||||||
#Build Stage
|
#buildJar-stage
|
||||||
#if npm is needed for development purposes, switch to node
|
FROM openjdk:22-jdk-slim as build-jar-stage
|
||||||
#FROM node:22-bookworm-slim as build-env
|
|
||||||
FROM ubuntu:latest as build-env
|
RUN \
|
||||||
|
--mount=type=cache,target=/var/cache/apt \
|
||||||
|
apt-get update && apt-get -qqy upgrade &&\
|
||||||
|
apt-get -qqy install git &&\
|
||||||
|
git clone --single-branch --branch main https://repo.prod.meissa.de/meissa/ModeratorElection.git /usr/local/src/ModeratorElection
|
||||||
|
WORKDIR /usr/local/src/ModeratorElection/
|
||||||
|
RUN ./gradlew build -Pvaadin.productionMode
|
||||||
|
|
||||||
|
# Run jar stage
|
||||||
|
FROM build-jar-stage AS run-jar-stage
|
||||||
|
EXPOSE 8080
|
||||||
|
WORKDIR /usr/local/src/ModeratorElection/build/libs/
|
||||||
|
RUN chmod 0740 ./ModeratorElection.jar
|
||||||
|
ENTRYPOINT ["java", "-jar", "./ModeratorElection.jar"]
|
||||||
|
|
||||||
|
|
||||||
|
#build-native-stage
|
||||||
|
FROM ubuntu:latest as build-native-stage
|
||||||
|
|
||||||
ADD resources /tmp
|
ADD resources /tmp
|
||||||
RUN /tmp/install.sh
|
RUN \
|
||||||
|
--mount=type=cache,target=/var/cache/apt \
|
||||||
|
/tmp/install.sh
|
||||||
ENV LANG=en_US.UTF-8 \
|
ENV LANG=en_US.UTF-8 \
|
||||||
JAVA_HOME=/usr/lib/jvm/graalvm
|
JAVA_HOME=/usr/lib/jvm/graalvm/bin
|
||||||
|
|
||||||
# Run stage
|
# Run native binary stage
|
||||||
FROM ubuntu:latest
|
FROM build-native-stage AS run-native-stage
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get -qqy upgrade
|
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
CMD ["mkdir /usr/local/src/ModeratorElection"]
|
#CMD ["mkdir /usr/local/src/ModeratorElection"]
|
||||||
WORKDIR /usr/local/src/ModeratorElection/
|
WORKDIR /usr/local/src/ModeratorElection/build/native/nativeCompile/
|
||||||
|
##copy native binary
|
||||||
#copy graalvm binary
|
#COPY --from=buildNative-stage /usr/local/src/ModeratorElection/build/native/nativeCompile/ .
|
||||||
COPY --from=build-env /usr/local/src/ModeratorElection/build/native/nativeCompile/ /usr/local/src/ModeratorElection/
|
|
||||||
RUN chmod 0740 ./ModeratorElection
|
RUN chmod 0740 ./ModeratorElection
|
||||||
ENTRYPOINT ["./ModeratorElection"]
|
ENTRYPOINT ["./ModeratorElection"]
|
|
@ -4,10 +4,9 @@ set -exo pipefail
|
||||||
|
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
upgradeSystem
|
#upgradeSystem
|
||||||
#unzpip only necessary for gradle installation within main()
|
apt-get update && apt-get -qqy upgrade
|
||||||
apt-get -qqy install curl git build-essential libz-dev zlib1g-dev
|
apt-get -qqy install curl git build-essential libz-dev zlib1g-dev
|
||||||
mkdir /usr/local/src/ModeratorElection
|
|
||||||
|
|
||||||
#change to main branch for production
|
#change to main branch for production
|
||||||
#change to MEapp-development branch for development
|
#change to MEapp-development branch for development
|
||||||
|
@ -21,8 +20,8 @@ function main()
|
||||||
#download graalvm
|
#download graalvm
|
||||||
#graalvm-community-jdk, v22.0.1 2024-04-16
|
#graalvm-community-jdk, v22.0.1 2024-04-16
|
||||||
graalvm_jdk_version="22.0.1"
|
graalvm_jdk_version="22.0.1"
|
||||||
curl -SsLo /tmp/graalvm-community-jdk.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graalvm_jdk_version}/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz
|
curl -SsLo /tmp/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-22.0.1/graalvm-community-jdk-22.0.1_linux-x64_bin.tar.gz
|
||||||
curl -SsLo /tmp/graalvm-checksum https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graalvm_jdk_version}/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz.sha256
|
curl -SsLo /tmp/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz.sha256 https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graalvm_jdk_version}/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz.sha256
|
||||||
|
|
||||||
#checksum graalvm
|
#checksum graalvm
|
||||||
checksum
|
checksum
|
||||||
|
@ -33,40 +32,45 @@ function main()
|
||||||
#nativeCompile
|
#nativeCompile
|
||||||
buildproc
|
buildproc
|
||||||
|
|
||||||
cleanupDocker
|
#cleanupDocker
|
||||||
|
rm -f /root/.ssh/authorized_keys
|
||||||
|
rm -f /root/.ssh/authorized_keys2
|
||||||
|
|
||||||
|
apt-get clean
|
||||||
|
apt-get -qqy autoremove --purge
|
||||||
|
apt-get -qqy autoclean
|
||||||
|
rm -rf /var/lib/apt/lists/
|
||||||
|
|
||||||
|
rm -rf /tmp/*
|
||||||
|
|
||||||
|
find /var/cache -type f -exec rm -rf {} \;
|
||||||
|
find /var/log/ -name '*.log' -exec rm -f {} \;
|
||||||
|
|
||||||
} > /dev/null
|
} > /dev/null
|
||||||
|
|
||||||
function checksum() {
|
function checksum() {
|
||||||
#graalvm
|
#graalvm
|
||||||
echo " /tmp/graalvm-jdk-${graalvm_JDK_version}_linux-x64_bin.tar.gz"|tee -a /tmp/graalvm-jdk-${graalvm_JDK_version}_linux-x64_bin.tar.gz.sha256
|
echo " /tmp/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz"|tee -a /tmp/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz.sha256
|
||||||
sha256sum -c --status /tmp/graalvm-jdk-${graalvm_JDK_version}_linux-x64_bin.tar.gz.sha256
|
sha256sum -c --status /tmp/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz.sha256
|
||||||
}
|
}
|
||||||
|
|
||||||
function graalvm_inst(){
|
function graalvm_inst(){
|
||||||
mkdir /usr/lib/jvm/
|
mkdir /usr/lib/jvm/
|
||||||
tar -C /usr/lib/jvm/ -xzf /tmp/graalvm-jdk-${graalvm_JDK_version}_linux-x64_bin.tar.gz
|
tar -C /usr/lib/jvm/ -xzf /tmp/graalvm-community-jdk-${graalvm_jdk_version}_linux-x64_bin.tar.gz
|
||||||
dirname_graalvm=$(ls /usr/lib/jvm/|grep -e graa)
|
dirname_graalvm=$(ls /usr/lib/jvm/|grep -e graa)
|
||||||
ln -s /usr/lib/jvm/$dirname_graalvm /usr/lib/jvm/graalvm
|
mkdir /usr/lib/jvm/graalvm/
|
||||||
ln -s /usr/lib/jvm/graalvm/bin/gu /usr/local/bin
|
ln -s /usr/lib/jvm/$dirname_graalvm/bin/ /usr/lib/jvm/graalvm/
|
||||||
update-alternatives --install /usr/bin/java java /usr/lib/jvm/graalvm/bin/java 0
|
update-alternatives --install /usr/bin/java java /usr/lib/jvm/graalvm/bin/java 0
|
||||||
|
echo "export PATH=$PATH:/usr/lib/jvm/graalvm/bin"| tee -a ~/.bashrc
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildproc() {
|
function buildproc() {
|
||||||
cd /usr/local/src/ModeratorElection/
|
cd /usr/local/src/ModeratorElection/
|
||||||
#for dev
|
#build graalvm binary
|
||||||
#npm install -g npm@latest
|
./gradlew nativeCompile -Dvaadin.productionMode=true -x processTestAot
|
||||||
#npm audit fix
|
|
||||||
#npm ci --omit=dev
|
|
||||||
|
|
||||||
#build jar
|
|
||||||
#./gradlew clean build -Pvaadin.productionMode -x processTestAot
|
|
||||||
#cp -r doc/META-INF src/main/resources
|
|
||||||
#build graalvm binary
|
|
||||||
./gradlew nativeCompile -Dvaadin.productionMode=true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
source /tmp/install_functions_debian.sh
|
#source /tmp/install_functions_debian.sh
|
||||||
DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes main
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes main
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue