-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathDockerfile
139 lines (114 loc) · 5.49 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
ARG MP_VERSION=devel
ARG MP_DIR=/opt/midpoint
ARG MP_DIST_FILE=midpoint-dist.tar.gz
ARG MP_DIST_INFO=N/A
ARG SKIP_DOWNLOAD=0
ARG maintainer=evolveum
ARG imagename=midpoint
ARG JAVA_VERSION=21
### values for Ubuntu based image ###
#ARG base_image=ubuntu
#ARG base_image_tag=22.04
####################################
### values for Rocky linux based image ###
#ARG base_image=rockylinux
#ARG base_image_tag=9.3
#####################################
### values for Alpine based image ###
ARG base_image=alpine
ARG base_image_tag=latest
#####################################
FROM ${base_image}:${base_image_tag}
ARG base_image
ARG MP_VERSION
ARG MP_DIR
ARG MP_DIST_FILE
ARG SKIP_DOWNLOAD
RUN if [ "${base_image}" = "ubuntu" ]; \
then apt-get update -y && apt-get install -y curl libxml2-utils ; \
else if [ "${base_image}" = "alpine" ]; \
then apk --update add --no-cache libxml2-utils curl bash ; \
fi ; fi
COPY download-midpoint map_midpoint-docker.csv common.bash ${MP_DIST_FILE}* ${MP_DIR}/
RUN if [ "${SKIP_DOWNLOAD}" = "0" ]; \
then chmod 755 ${MP_DIR}/download-midpoint && \
${MP_DIR}/download-midpoint ${MP_VERSION} ${MP_DIST_FILE} ; \
fi ; \
tar -xzC ${MP_DIR} -f ${MP_DIR}/${MP_DIST_FILE} --strip-components=1 ; \
rm -f ${MP_DIR}/${MP_DIST_FILE}* ${MP_DIR}/download-midpoint ${MP_DIR}/map_midpoint-docker.csv ${MP_DIR}/common.bash
##### 2022/05/02 - "reaction" to adding jar package to dist archive ######
# Once both jar and war is present the only jar is needed. During transition perion the
# symlink is created to prevent the fails because of not updated starting script
# ... docker related file have a little bit different lifecycle than midpoint files ...
##########################################################################
RUN if [ -e ${MP_DIR}/lib/midpoint.jar ]; \
then ln -sf midpoint.jar ${MP_DIR}/lib/midpoint.war ; fi
FROM ${base_image}:${base_image_tag} as java-17
ENV MP_SET_midpoint_repository_database=h2 \
MP_SET_midpoint_repository_jdbcUrl=jdbc:h2:tcp://localhost:5437/midpoint \
MP_SET_midpoint_repository_hibernateHbm2ddl=none \
MP_SET_midpoint_repository_initializationFailTimeout=60000 \
MP_SET_midpoint_repository_missingSchemaAction=create \
MP_SET_midpoint_repository_upgradeableSchemaAction=stop
FROM ${base_image}:${base_image_tag} as java-21
ENV MP_SET_midpoint_repository_database=h2 \
MP_SET_midpoint_repository_jdbcUrl=jdbc:h2:tcp://localhost:5437/./midpoint;DB_CLOSE_ON_EXIT=FALSE;LOCK_MODE=1;LOCK_TIMEOUT=100;MAX_LENGTH_INPLACE_LOB=10240;NON_KEYWORDS=VALUE \
MP_SET_midpoint_repository_hibernateHbm2ddl=none \
MP_SET_midpoint_repository_initializationFailTimeout=60000 \
MP_SET_midpoint_repository_missingSchemaAction=create \
MP_SET_midpoint_repository_upgradeableSchemaAction=stop
FROM java-${JAVA_VERSION}
ARG MP_DIR
ARG MP_VERSION
ARG MP_DIST_INFO
ARG base_image
ARG base_image_tag
ARG maintainer
ARG imagename
ARG JAVA_VERSION
LABEL Vendor="${maintainer}"
LABEL ImageType="base"
LABEL ImageName="${imagename}"
LABEL ImageOS="${base_image}:${base_image_tag}"
LABEL Version="${MP_VERSION}"
LABEL AppBuildID="${MP_DIST_INFO}"
LABEL org.opencontainers.image.authors="[email protected]"
ENV MP_SET_file_encoding=UTF8 \
MP_SET_midpoint_logging_alt_enabled=true \
MP_MEM_MAX=2048m \
MP_MEM_INIT=1024m \
TZ=UTC \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
MP_DIR=${MP_DIR}
COPY container_files/usr-local-bin/* /usr/local/bin/
RUN if [ "${base_image}" = "ubuntu" ]; \
then sed 's/main$/main universe/' -i /etc/apt/sources.list && \
apt-get update -y && \
apt-get install -y openjdk-${JAVA_VERSION}-jre-headless tzdata curl language-pack-en && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*/tmp/* /var/tmp/* ; \
else if [ "${base_image}" = "rockylinux" ]; \
then dnf update -y && dnf install -y java-${JAVA_VERSION}-openjdk-headless tzdata bash which glibc-langpack-en && dnf clean all -y ; \
else apk --update add --no-cache openjdk${JAVA_VERSION}-jre-headless curl libxml2-utils tzdata bash fontconfig ttf-dejavu musl musl-utils musl-locales ; \
fi ; fi ; \
mkdir -p "${MP_DIR}/bin/" ; \
if [ ! -e "${MP_DIR}/bin/setenv.sh" ] ; then echo "#!/usr/bin/env bash" > "${MP_DIR}/bin/setenv.sh" ; fi ; \
echo -n "export JAVA_HOME=" >> "${MP_DIR}/bin/setenv.sh" ; \
find /usr/lib/jvm -maxdepth 1 -name "*openjdk*" -name "*${JAVA_VERSION}*" -type d | head -1 >> ${MP_DIR}/bin/setenv.sh ; \
echo "[ \$(echo \${PATH} | grep -c openjdk) -eq 0 ] && PATH=\${PATH}:\${JAVA_HOME}/bin" >>${MP_DIR}/bin/setenv.sh
VOLUME ${MP_DIR}/var
HEALTHCHECK --interval=1m --timeout=30s --start-period=2m CMD /usr/local/bin/healthcheck.sh
EXPOSE 8080
CMD [ "/opt/midpoint/bin/midpoint.sh", "container" ]
RUN echo "fix for starting midpoint around release 4.2..." ; \
if [ $(grep -c "\-cp \"\${BASE_DIR}/lib/midpoint.war\"" ${MP_DIR}/bin/midpoint.sh ) -eq 1 ] ; then \
sed -i "/^[[:space:]]*-jar \"\${BASE_DIR}\/lib\/midpoint.war\"/a \ \ \ \ -Dloader.path=\"WEB-INF/classes,WEB-INF/lib,WEB-INF/lib-provided,${MP_DIR}/lib/\" org.springframework.boot.loader.PropertiesLauncher \\\\" /usr/local/bin/midpoint.sh ; \
sed -i "s/^[[:space:]]*-jar \"\${BASE_DIR}\/lib\/midpoint.war\"/ -cp \"\${BASE_DIR}\/lib\/midpoint.war\"/g" /usr/local/bin/midpoint.sh ; \
echo "\"old\" -cp style start found and updated..." ; \
fi ; \
echo "end of fix check..." ; \
if [ $(grep -c "container" ${MP_DIR}/bin/midpoint.sh) -eq 0 ]; then \
cp /usr/local/bin/midpoint.sh ${MP_DIR}/bin/midpoint.sh && echo "midpoint.sh file replaced" ; fi
COPY --from=0 ${MP_DIR} ${MP_DIR}/