blob: bf64aae494e8fb5fe8cd109121bb8073c24a884c [file] [log] [blame]
elinuxhenrik115e1092022-04-05 09:29:33 +02001# ============LICENSE_START===============================================
2# Copyright (C) 2020 Nordix Foundation. All rights reserved.
3# ========================================================================
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# ============LICENSE_END=================================================
16#
17
JohnKeeney04968202023-03-27 14:50:22 +010018FROM curlimages/curl:7.78.0 AS base-build
elinuxhenrik115e1092022-04-05 09:29:33 +020019
20#Get helm
21RUN curl -Lo /tmp/helm.tar.gz https://get.helm.sh/helm-v3.6.1-linux-amd64.tar.gz
22
23#Get kubectl
24RUN curl -Lo /tmp/kubectl https://dl.k8s.io/release/v1.20.2/bin/linux/amd64/kubectl
25
JohnKeeney04968202023-03-27 14:50:22 +010026#Get JDK & shrink it to equivalent to a JRE
27FROM openjdk:17-jdk as jre-build
elinuxhenrik115e1092022-04-05 09:29:33 +020028
JohnKeeney04968202023-03-27 14:50:22 +010029RUN $JAVA_HOME/bin/jlink \
30 --verbose \
31 --add-modules ALL-MODULE-PATH \
32 --strip-debug \
33 --no-man-pages \
34 --no-header-files \
35 --compress=2 \
36 --output /customjre
elinuxhenrik115e1092022-04-05 09:29:33 +020037
JohnKeeney04968202023-03-27 14:50:22 +010038# Use debian base image (same as openjdk uses)
39FROM debian:11-slim
elinuxhenrik115e1092022-04-05 09:29:33 +020040
JohnKeeney04968202023-03-27 14:50:22 +010041#Install helm from base-build image
42COPY --from=base-build /tmp/helm.tar.gz .
43RUN tar -zxvf helm.tar.gz && \
44 mv linux-amd64/helm /usr/local/bin/helm
elinuxhenrik115e1092022-04-05 09:29:33 +020045
JohnKeeney04968202023-03-27 14:50:22 +010046#Install kubectl from base-build image
47COPY --from=base-build /tmp/kubectl .
48RUN chmod +x ./kubectl && \
49 mv ./kubectl /usr/local/bin/kubectl
elinuxhenrik115e1092022-04-05 09:29:33 +020050
JohnKeeney04968202023-03-27 14:50:22 +010051#Copy JRE from the jre-base image
52ENV JAVA_HOME=/jre
53ENV PATH=${JAVA_HOME}/bin:${PATH}
54COPY --from=jre-build /customjre $JAVA_HOME
elinuxhenrik115e1092022-04-05 09:29:33 +020055
elinuxhenrik115e1092022-04-05 09:29:33 +020056
57WORKDIR /etc/app/helm-manager
58COPY config/application.yaml .
59
60WORKDIR /opt/app/helm-manager
61COPY target/app.jar app.jar
62
63ARG user=nonrtric
64ARG group=nonrtric
65
66RUN groupadd $group && \
JohnKeeney04968202023-03-27 14:50:22 +010067 useradd -r -g $group $user && \
68 chown -R $user:$group /opt/app/helm-manager && \
69 chown -R $user:$group /etc/app/helm-manager
elinuxhenrik115e1092022-04-05 09:29:33 +020070
JohnKeeney04968202023-03-27 14:50:22 +010071RUN mkdir /var/helm-manager-service && \
72 chown -R $user:$group /var/helm-manager-service
elinuxhenrik115e1092022-04-05 09:29:33 +020073
JohnKeeney04968202023-03-27 14:50:22 +010074RUN mkdir /home/$user && \
75 chown -R $user:$group /home/$user
elinuxhenrik115e1092022-04-05 09:29:33 +020076
77USER $user
78
79CMD [ "java", "-jar", "app.jar", "--spring.config.location=optional:file:/etc/app/helm-manager/"]