-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile.alpine
145 lines (125 loc) · 3.89 KB
/
Dockerfile.alpine
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
140
141
142
143
144
145
FROM maven:3-jdk-8-slim AS builder
RUN set -ex; \
apt-get update; \
apt-get install -y --allow-unauthenticated \
git \
graphviz \
; \
dot -V; \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY docker/maven/settings-docker.xml /usr/share/maven/ref/settings-docker.xml
COPY . .
# Maven arguments
ARG MAVEN_PROFILE=dev
# Credentials to private Package Repository
ARG PACKAGE_REPO_LOGIN
ARG PACKAGE_REPO_PASSWORD
RUN set -ex; \
mvn \
clean \
test \
verify \
package \
-DskipTests=false \
-Dmaven.javadoc.skip=true \
-B \
-V \
-s /usr/share/maven/ref/settings-docker.xml \
-P "${MAVEN_PROFILE:-dev}" \
; \
ls -al target; \
mv target/*.jar target/app.jar; \
ls -al target
FROM openjdk:8-jre-alpine
# Expected JAR file path as argument
ARG JAR_FILE=/usr/src/app/target/app.jar
# Setup application folders and tools
# install dependencies
RUN set -ex; \
mkdir -p /srv/app; \
chmod 755 /srv/app; \
mkdir -p /srv/app/data; \
mkdir -p /srv/app/logs; \
mkdir -p /srv/app/keys; \
mkdir -p /srv/app/config; \
apk add --update \
libpq \
mariadb-common \
openssh-keygen \
openssl \
zlib \
; \
rm -rf /var/cache/apk/*
VOLUME /srv/app/config /srv/app/keys /srv/app/logs /srv/app/data
WORKDIR /srv/app/
EXPOSE 8080 8443
# Application configuration
# Database configuration
# Mail configuration
ENV \
APP_TITLE=App \
APP_CONFIG=/srv/app/config/application.properties \
APP_SERVER_CONTEXT_PATH=/api \
APP_SERVER_PORT=8080 \
APP_MAX_FILE_SIZE=20MB \
APP_MAX_REQUEST_SIZE=20MB \
APP_DOMAIN_NAME=example.com \
APP_ADMIN_PASSWORD=youshouldoverwritethiswithsomethingelse \
APP_SIGNING_KEY=youshouldoverwritethiswithsomethingelse \
APP_SIGNING_KEYPAIR_PASS='' \
APP_SIGNING_KEYPAIR_ALIAS=spring_rest_api_starter_key \
APP_DEMO_DATA=false \
DB_DIALECT='' \
DB_STORAGE='' \
DB_DRIVER='' \
DB_PLATFORM='h2' \
DB_HOST='' \
DB_PORT='' \
DB_NAME='spring_rest_api_starter' \
DB_USER='spring_rest_api_starter' \
DB_PASSWORD='spring_rest_api_starter_password' \
MAIL_HOST= \
MAIL_PORT= \
MAIL_PROTOCOL= \
MAIL_USER= \
MAIL_PASSWORD= \
MAIL_SSL=false \
MAIL_STARTTLS=false
# Copy entrypoint and expected JAR file in container
COPY docker-entrypoint.sh /entrypoint.sh
COPY --from=builder ${JAR_FILE} /srv/app/app.jar
RUN set -ex; \
chmod 755 /entrypoint.sh /srv/app/app.jar
ENTRYPOINT ["sh", "/entrypoint.sh"]
CMD ["java", "-jar", "app.jar"]
# Arguments to label built container
ARG TAG=unknown
ARG VCS_REF=unknown
ARG BUILD_DATE=unknown
# Keep track of image version
RUN set -ex; \
echo "${TAG} ${VCS_REF} ${BUILD_DATE}" > '/srv/app/.docker-app-version'
# Container labels (http://label-schema.org/)
# Container annotations (https://github.com/opencontainers/image-spec)
LABEL maintainer="Monogramm Maintainers <opensource at monogramm dot io>" \
product="SPRING-REST-API" \
version=$TAG \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/Monogramm/spring-rest-api-starter/" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="SPRING-REST-API" \
org.label-schema.description="Spring RESTful API." \
org.label-schema.url="https://github.com/Monogramm/spring-rest-api-starter/" \
org.label-schema.vendor="Monogramm" \
org.label-schema.version=$TAG \
org.label-schema.schema-version="1.0" \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.source="https://github.com/Monogramm/spring-rest-api-starter/" \
org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.title="SPRING-REST-API" \
org.opencontainers.image.description="Spring RESTful API." \
org.opencontainers.image.url="https://github.com/Monogramm/spring-rest-api-starter/" \
org.opencontainers.image.vendor="Monogramm" \
org.opencontainers.image.version=$TAG \
org.opencontainers.image.authors="Monogramm Maintainers <opensource at monogramm dot io>"