-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
SQ
committed
Jan 18, 2024
1 parent
de537ad
commit 2ba1597
Showing
7 changed files
with
93 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,25 @@ | ||
#编译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 eclipse-temurin:17-jre-alpine | ||
|
||
#运行镜像 | ||
FROM centos:7 | ||
|
||
# 时区与字符设置UTF-8并配置环境 | ||
ENV TZ=Asia/Shanghai | ||
ENV LANG=C.UTF-8 | ||
ENV apiPort="8099" | ||
ENV webPort="80" | ||
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 | ||
|
||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /build/target/MusicServer2.0.jar /app/app.jar | ||
RUN mkdir -p /usr/local/nginx/conf/ | ||
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 ${webPort}; server_name localhost; location / { root html; index index.html index.htm; } location /sqmusic-api/ { proxy_pass http://localhost:${apiPort}/; proxy_http_version 1.1; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }}" > /usr/local/nginx/conf/nginx.conf | ||
|
||
EXPOSE 8099 | ||
|
||
#将启动脚本拷贝到容器里面的/usr/local/project下面 | ||
COPY docker-run.sh /usr/local/project/docker-run.sh | ||
#给run.sh可执行权限 | ||
RUN chmod 777 /usr/local/project/docker-run.sh | ||
VOLUME ["/music"] | ||
|
||
#对外暴露80,8880端口,暴不暴露端口没有什么影响,重要的是要在启动的时候使用-p映射宿主机端口:容器端口,暴露端口你也得使用-p映射端口 | ||
EXPOSE ${apiPort} ${webPort} | ||
VOLUME ["/cache"] | ||
|
||
#nginx -c -t /software/nginx/nginx.conf | ||
CMD ["java", "-jar", "app.jar"] | ||
|
||
#通过脚本同时启动后端jar包和nginx | ||
CMD ["sh","/usr/local/project/docker-run.sh","${apiPort}","${webPort}"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 26 additions & 26 deletions
52
src/main/java/com/sqmusicplus/controller/FreemarkerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
//package com.sqmusicplus.controller; | ||
package com.sqmusicplus.controller; | ||
|
||
import cn.dev33.satoken.annotation.SaCheckLogin; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
/** | ||
* @Classname FreemarkerController | ||
* @Description TODO | ||
* @Version 1.0.0 | ||
* @Date 2023/9/21 18:29 | ||
* @Created by Administrator | ||
*/ | ||
@Slf4j | ||
@Controller | ||
@RequestMapping | ||
public class FreemarkerController { | ||
|
||
@RequestMapping(value = {"/","/index"}) | ||
public String search(){ | ||
return "redirect:/index.html"; | ||
} | ||
// @RequestMapping(value = {"/login"}) | ||
// public String login(){ | ||
// | ||
//import cn.dev33.satoken.annotation.SaCheckLogin; | ||
//import lombok.extern.slf4j.Slf4j; | ||
//import org.springframework.stereotype.Controller; | ||
//import org.springframework.web.bind.annotation.RequestMapping; | ||
// | ||
///** | ||
// * @Classname FreemarkerController | ||
// * @Description TODO | ||
// * @Version 1.0.0 | ||
// * @Date 2023/9/21 18:29 | ||
// * @Created by Administrator | ||
// */ | ||
//@Slf4j | ||
//@Controller | ||
//@RequestMapping | ||
//public class FreemarkerController { | ||
// | ||
// @RequestMapping(value = {"/","/index"}) | ||
// public String search(){ | ||
// return "redirect:/index.html"; | ||
// } | ||
//// @RequestMapping(value = {"/login"}) | ||
//// public String login(){ | ||
//// | ||
//// return "redirect:/index.html"; | ||
//// } | ||
//} | ||
} |