-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathDockerfile
50 lines (36 loc) · 1.39 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
# Source Docker image from https://hub.docker.com/
FROM eclipse-temurin:17-jdk-alpine as builder
# Working directory in Docker
WORKDIR /app
# Copy the application to the Docker working directory
COPY target/*.jar app.jar
# Extract layers of application's jar
RUN java -Djarmode=layertools -jar app.jar extract
# Multi-Stage Build
FROM eclipse-temurin:17-jre-alpine
# Port used to connect with the application
ENV SERVER_PORT 8180
EXPOSE $SERVER_PORT
# Default symmetric encryption key
ARG ENCRYPT_KEY=ENCRYPT_KEY
ENV ENCRYPT_KEY ${ENCRYPT_KEY}
# Default Spring profile
ENV SPRING_PROFILES_ACTIVE docker
VOLUME /tmp
ARG DEPENDENCY=/app
COPY --from=builder ${DEPENDENCY}/dependencies/ ./
COPY --from=builder ${DEPENDENCY}/spring-boot-loader/ ./
COPY --from=builder ${DEPENDENCY}/snapshot-dependencies/ ./
COPY --from=builder ${DEPENDENCY}/application/ ./
# Copy the Spring Boot fat JarLauncher into the image and use it to run the application
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
# ------------------------------------------------------------------------------------------
# COMMANDS:
#
# 1. Build the image in local:
#
# docker build -t security-jwt-service . -f ./Dockerfile
#
# 2. Build and launch the container:
#
# docker run -p 8180:8180 --rm --name security-jwt-service --add-host=host.docker.internal:host-gateway --network Spring5Microservices security-jwt-service