-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_DockerFile
63 lines (54 loc) · 1.16 KB
/
project_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
# docker build . -t project_name:1.0
#
# Set a variable that can be used in all stages.
#
ARG BUILD_HOME=/project_name
#
# Gradle image for the build stage.
#
FROM gradle:jdk11 as build-image
#
# Set the working directory.
#
ARG BUILD_HOME
ENV APP_HOME=$BUILD_HOME
WORKDIR $APP_HOME
#
# Copy the Gradle config, source code, and static analysis config
# into the build container.
#
COPY --chown=gradle:gradle build.gradle.kts settings.gradle.kts $APP_HOME/
COPY --chown=gradle:gradle src $APP_HOME/src
#
# Build the application.
#
RUN gradle --no-daemon build
#
# Java image for the application to run in.
#
FROM openjdk:12-alpine
#
# Copy the jar file in and name it app.jar.
#
ARG BUILD_HOME
ENV APP_HOME=$BUILD_HOME
COPY --from=build-image $APP_HOME/build/libs/*.jar project_name-app.jar
#
# The command to run when the container starts.
#
ENTRYPOINT java -jar project_name-app.jar
## with maven
# FROM openjdk:11 As build
#
# COPY pom.xml mvnw ./
# COPY .mvn .mvn
# RUN ./mvnw dependency:resolve
#
# COPY src src
# RUN ./mvnw package
#
# FROM openjdk:11
# WORKDIR project_name
# COPY --from=build target/*.jar project_name.jar
# ENTRYPOINT ["java", "-jar", "project_name.jar"]
##