-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
73 lines (60 loc) · 2.09 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
#FROM maven:3.5-jdk-8-alpine as builder
#
## Copy local code to the container image.
#WORKDIR /app
#COPY pom.xml .
#COPY src ./src
#COPY setting.xml .
#
## Build a release artifact.
#RUN mvn package -DskipTests
#
## Run the web service on container startup.
#CMD ["java","-jar","/app/target/user_center-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"]
## First stage: complete build environment
#FROM maven:3.5.0-jdk-8-alpine AS builder
#
## download dependencies (no re-download when the source code changes)
#ADD ./pom.xml pom.xml
## RUN mvn install
#
#ADD ./src src/
## package jar
## RUN mvn install -Dmaven.test.skip=true
#
#
## copy jar from the first stage
#COPY --from=builder target/user_center-0.0.1-SNAPSHOT.jar user_center-0.0.1-SNAPSHOT.jar
#EXPOSE 8081
#CMD ["java", "-jar", "user_center-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"]
# 基于java镜像创建新镜像
#FROM maven:3.5-jdk-8-alpine as builder
## 作者
#MAINTAINER Louisbrilliant
## Build a release artifact.
#RUN mvn package -DskipTests
## 将jar包添加到容器中并更名为app.jar
#ADD target/user_center-0.0.1-SNAPSHOT.jar /root/docker_test/app.jar
## 运行jar包
#ENTRYPOINT ["nohup","java","-jar","/root/docker_test/app.jar","--spring.profiles.active=prod"]
#FROM openjdk:8-jdk-alpine
#COPY target/user_center-0.0.1-SNAPSHOT.jar /app/user_center-0.0.1-SNAPSHOT.jar
#WORKDIR /app
#EXPOSE 8081
#CMD ["java", "-jar", "user_center-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"]
#基础镜像使用java
#FROM openjdk:8u312-jre-slim-buster
#COPY target/user_center-0.0.1-SNAPSHOT.jar /app/user_center-0.0.1-SNAPSHOT.jar
#WORKDIR /app
#EXPOSE 8081
#CMD ["java", "-jar", "user_center-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"]
FROM centos
COPY target/user_center-0.0.1-SNAPSHOT.jar /app/user_center-0.0.1-SNAPSHOT.jar
ADD jdk-8u381-linux-x64.tar.gz /app/
WORKDIR /app
#5.配置环境变量
ENV JAVA_HOME=/app/jdk1.8.0_381
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH=$JAVA_HOME/bin:$PATH
EXPOSE 8081
CMD ["java", "-jar", "user_center-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"]