-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDockerfile_dddd
57 lines (39 loc) · 2.12 KB
/
Dockerfile_dddd
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
#编译jar包
FROM maven:3.9.4-eclipse-temurin-17-alpine AS builder
MAINTAINER SQ
WORKDIR /build/
#复制源码信息
COPY pom.xml /build/
COPY src /build/src/
COPY src/main/resources/sqlite/sqmusic.db /cache/sqmusic.db
#打包
RUN mvn clean package
#运行镜像
FROM centos:7
# 时区与字符设置UTF-8并配置环境
ENV TZ=Asia/Shanghai
ENV LANG=C.UTF-8
ENV TimeZone=Asia/Shanghai
#
#RUN yum makecache
RUN yum update -y wget
RUN rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
RUN yum install -y nginx
RUN yum install -y wget
RUN wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm
RUN yum install -y ./jdk-17_linux-x64_bin.rpm
#RUN wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.18.0-1.el7.ngx.x86_64.rpm
#RUN yum install -y ./nginx-1.18.0-1.el7.ngx.x86_64.rpm
COPY src/main/resources/static /html/
RUN rm /etc/nginx/nginx.conf
COPY --from=builder /build/target/MusicServer2.0.jar /app/app.jar
RUN echo "worker_processes 1;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /html; index index.html index.htm; } location /sqmusic-api/ { proxy_pass http://localhost:8099/; proxy_http_version 1.1; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }}" > /etc/nginx/nginx.conf
#将启动脚本拷贝到容器里面的/usr/local/project下面
COPY docker-run.sh /usr/local/project/docker-run.sh
#给run.sh可执行权限
RUN chmod 777 /usr/local/project/docker-run.sh
#对外暴露80,8880端口,暴不暴露端口没有什么影响,重要的是要在启动的时候使用-p映射宿主机端口:容器端口,暴露端口你也得使用-p映射端口
#EXPOSE ${apiPort} ${webPort}
#nginx -c -t /software/nginx/nginx.conf
#通过脚本同时启动后端jar包和nginx
CMD ["sh","/usr/local/project/docker-run.sh","8099","80"]