-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
64 lines (51 loc) · 1.79 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
FROM openjdk:8-jdk-alpine
ENV SVC_HOME=/opt/microservice
ENV SVC_ETC=${SVC_HOME}/etc SVC_LIB=${SVC_HOME}/lib SVC_CACHE=/var/cache/microservice BOOTSTRAP=${SVC_HOME}/bootstrap.sh
RUN addgroup --system microservice \
&& adduser --system --ingroup microservice --home $SVC_HOME microservice
ADD src/files ${SVC_ETC}/
ADD bootstrap.sh ${BOOTSTRAP}
RUN mkdir -p $SVC_LOG $SVC_CACHE $SVC_ETC \
&& chown -R microservice:microservice $SVC_LOG $SVC_CACHE $SVC_HOME \
&& chmod +x ${BOOTSTRAP}
USER microservice
ONBUILD ARG JAR_FILE
ONBUILD ARG ARTIFACT_ID
ONBUILD ARG GROUP_ID
ONBUILD ARG VERSION
ONBUILD ARG name=$ARTIFACT_ID
ONBUILD ARG description="unknown"
ONBUILD ARG usage="/README.md"
ONBUILD ARG url="unknnown"
ONBUILD ARG vcs_url="unknown"
ONBUILD ARG vcs_branch="unknown"
ONBUILD ARG vcs_ref="unknown"
ONBUILD ARG build_date="unknown"
ONBUILD LABEL org.label-schema.vendor="My Company" \
org.label-schema.name=$name \
org.label-schema.description=$description \
org.label-schema.usage=$usage \
org.label-schema.url=$url \
org.label-schema.vcs-url=$vcs_url\
org.label-schema.vcs-branch=$vcs_branch \
org.label-schema.vcs-ref=$vcs_ref\
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
org.label-schema.build-date=$build_date \
java.version=${JAVA_VERSION} \
java.alpine.version=${JAVA_ALPINE_VERSION}
ONBUILD ENV \
ARTIFACT_ID=${ARTIFACT_ID} \
GROUP_ID=${GROUP_ID} \
VERSION=${VERSION} \
LOG_LEVEL=INFO \
CACHE_DIR=${SVC_CACHE}/${ARTIFACT_ID} \
ETC_DIR=${SVC_ETC}/${ARTIFACT_ID} \
MICROSERVICE=${SVC_HOME}/${JAR_FILE}
ONBUILD ADD target/lib ${SVC_LIB}/
ONBUILD ADD target/${JAR_FILE} ${MICROSERVICE}
# HTTP
ONBUILD EXPOSE 9000
# JMX
ONBUILD EXPOSE 8181
ONBUILD ENTRYPOINT ["/opt/microservice/bootstrap.sh"]