elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 1 | # ============LICENSE_START=============================================== |
ktimoney | 7d85344 | 2023-09-01 14:20:20 +0100 | [diff] [blame] | 2 | # Copyright (C) 2020-2023 Nordix Foundation. All rights reserved. |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 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 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 18 | FROM curlimages/curl:7.78.0 AS base-build |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 19 | |
| 20 | #Get helm |
ktimoney | 7d85344 | 2023-09-01 14:20:20 +0100 | [diff] [blame] | 21 | RUN wget -O /tmp/helm.tar.gz https://nexus.o-ran-sc.org/content/repositories/helm/helm-v3.6.1-linux-amd64.tar.gz |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 22 | |
| 23 | #Get kubectl |
ktimoney | 7d85344 | 2023-09-01 14:20:20 +0100 | [diff] [blame] | 24 | RUN wget -O /tmp/kubectl https://nexus.o-ran-sc.org/content/repositories/kubectl/v1.20.2/bin/linux/amd64/kubectl |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 25 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 26 | #Get JDK & shrink it to equivalent to a JRE |
| 27 | FROM openjdk:17-jdk as jre-build |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 28 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 29 | RUN $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 |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 37 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 38 | # Use debian base image (same as openjdk uses) |
| 39 | FROM debian:11-slim |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 40 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 41 | #Install helm from base-build image |
| 42 | COPY --from=base-build /tmp/helm.tar.gz . |
| 43 | RUN tar -zxvf helm.tar.gz && \ |
| 44 | mv linux-amd64/helm /usr/local/bin/helm |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 45 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 46 | #Install kubectl from base-build image |
| 47 | COPY --from=base-build /tmp/kubectl . |
| 48 | RUN chmod +x ./kubectl && \ |
| 49 | mv ./kubectl /usr/local/bin/kubectl |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 50 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 51 | #Copy JRE from the jre-base image |
| 52 | ENV JAVA_HOME=/jre |
| 53 | ENV PATH=${JAVA_HOME}/bin:${PATH} |
| 54 | COPY --from=jre-build /customjre $JAVA_HOME |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 55 | |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 56 | |
| 57 | WORKDIR /etc/app/helm-manager |
| 58 | COPY config/application.yaml . |
| 59 | |
| 60 | WORKDIR /opt/app/helm-manager |
| 61 | COPY target/app.jar app.jar |
| 62 | |
| 63 | ARG user=nonrtric |
| 64 | ARG group=nonrtric |
| 65 | |
| 66 | RUN groupadd $group && \ |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 67 | useradd -r -g $group $user && \ |
| 68 | chown -R $user:$group /opt/app/helm-manager && \ |
| 69 | chown -R $user:$group /etc/app/helm-manager |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 70 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 71 | RUN mkdir /var/helm-manager-service && \ |
| 72 | chown -R $user:$group /var/helm-manager-service |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 73 | |
JohnKeeney | 0496820 | 2023-03-27 14:50:22 +0100 | [diff] [blame] | 74 | RUN mkdir /home/$user && \ |
| 75 | chown -R $user:$group /home/$user |
elinuxhenrik | 115e109 | 2022-04-05 09:29:33 +0200 | [diff] [blame] | 76 | |
| 77 | USER $user |
| 78 | |
| 79 | CMD [ "java", "-jar", "app.jar", "--spring.config.location=optional:file:/etc/app/helm-manager/"] |