-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
72 lines (55 loc) · 1.7 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
ARG application_name=simple-file-drive
ARG spring_profile=prod
ARG username=admin
ARG password=admin
ARG max_file_size=1GB
ARG max_request_size=1GB
## Build stage
FROM adoptopenjdk:11-jdk-hotspot-bionic AS builder
ARG REFRESHED_AT
ENV REFRESHED_AT $REFRESHED_AT
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -qq
RUN apt-get install -qq --no-install-recommends \
nodejs \
yarn
RUN rm -rf /var/lib/apt/lists/*
COPY frontend frontend
COPY gradle gradle
COPY src src
COPY build.gradle .
COPY gradlew .
COPY settings.gradle .
RUN chmod +x ./gradlew
RUN ./gradlew build
## Release stage
FROM adoptopenjdk/openjdk11:alpine-jre
ARG application_name
ARG spring_profile
ARG username
ARG password
ARG max_file_size
ARG max_request_size
ENV APPLICATION=${application_name}
ENV WORKDIR=/home/${APPLICATION}
ENV DATA_PATH=${WORKDIR}/data
ENV SPRING_ACTIVE_PROFILE=${spring_profile}
RUN addgroup -S ${APPLICATION} && \
adduser -S ${APPLICATION} -G ${APPLICATION}
RUN mkdir -p ${WORKDIR}
RUN chown -R ${APPLICATION}:${APPLICATION} ${WORKDIR}
WORKDIR ${WORKDIR}
RUN mkdir -p ${DATA_PATH}
RUN chown -R ${APPLICATION}:${APPLICATION} ${DATA_PATH}
COPY --from=builder build/libs/*.war ./application.war
USER ${APPLICATION}
ENV USER_NAME=${username}
ENV PASSWORD=${password}
ENV MAX_FILE_SIZE=${max_file_size}
ENV MAX_REQUEST_SIZE=${max_request_size}
ENV BASE_PATH=${DATA_PATH}
EXPOSE 8080
ENTRYPOINT ["java", "-Dspring.profiles.active=${SPRING_ACTIVE_PROFILE}", "-jar", "./application.war"]