This commit is contained in:
none 2023-05-30 11:38:49 +08:00
commit d861eaf710
6 changed files with 124 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
frontend/
backend/

22
Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM eclipse-temurin:17-alpine
LABEL maintainer="0xtyz <tengyongzhi@meedu.vip>"
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories && \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories && \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories
# 安装基本组件
RUN apk update && apk add nginx
RUN mkdir /app
# Copy代码
COPY frontend /app/frontend
COPY backend /app/backend
COPY api /app/api
COPY conf/nginx.conf /etc/nginx/http.d/default.conf
RUN chmod +x /app/api/start.sh
ENTRYPOINT ["/app/api/start.sh"]

43
README.md Normal file
View File

@ -0,0 +1,43 @@
### PlayEdu Light Docker 构建方案
本套方案将 API + PC 前台 + 后台管理 三个整合在一个镜像当中,适用于轻量级客户。
### 上手
- API 程序 `package` 之后,将 `jar` 包复制到 `api` 目录下,并重新命名为 `app.jar`
- PC 界面程序 build 之后,将 `dist` 目录复制到本项目的根目录,然后重命名为 `frontend`
- 后台界面程序 build 之后,将 `dist` 目录复制到本项目的根目录,然后重命名为 `backend`
之后,在本项目目录命令执行:
```
docker build -t playedu-light .
```
执行完毕之后,可运行下面命令将 PlayEdu 服务跑起来:
```
docker run -d -p 9898:80 --name playedu-local \
-e DB_HOST=数据库host \
-e DB_PORT=数据库端口 \
-e DB_NAME=数据库名 \
-e DB_USER=数据库用户 \
-e DB_PASS=数据库密码 \
-e REDIS_HOST=Redis的host \
-e REDIS_PORT=Redis的端口 \
-e REDIS_PASS=redis的密码 \
-e MINIO_USER=minio的accessKey \
-e MINIO_PASS=minio的secretKey \
-e MINIO_END_POINT=minio的服务地址 \
-e MINIO_BUCKET=minio的bucket \
-e MINIO_DOMAIN=minio的访问域名 \
playedu-light
```
跑起来之后,可以通过下面的链接访问前后台:
| 端口 | 地址 |
| -------- | ----------------------------- |
| 学员界面 | `http://localhost:9898` |
| 后台管理 | `http://localhost:9898/admin` |
| API 服务 | `http://localhost:9898/api` |

3
api/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!.gitignore
!start.sh

5
api/start.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
nginx
java -jar /app/api/app.jar --spring.profiles.active=prod --spring.datasource.url="jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false" --spring.datasource.username=${DB_USER} --spring.datasource.password=${DB_PASS} --spring.data.redis.host=${REDIS_HOST} --spring.data.redis.port=${REDIS_PORT} --spring.data.redis.password=${REDIS_PASS} --minio.access-key=${MINIO_USER} --minio.secret-key=${MINIO_PASS} --minio.end-point=${MINIO_END_POINT} --minio.bucket=${MINIO_BUCKET} --minio.domain=${MINIO_DOMAIN}

49
conf/nginx.conf Normal file
View File

@ -0,0 +1,49 @@
server {
listen 80 default_server;
absolute_redirect off;
server_name _;
root /app/frontend;
index index.html;
location / {
try_files $uri $uri/ /index.html;
gzip on;
gzip_static on;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types text/plain application/javascript text/css application/xml text/javascript;
gzip_vary on;
}
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9898/;
}
location /admin {
alias /app/backend;
index index.html;
try_files $uri $uri/ /admin/index.html;
gzip on;
gzip_static on;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types text/plain application/javascript text/css application/xml text/javascript;
gzip_vary on;
}
location ~ /\.ht {
deny all;
}
location ~* ^/(?![api|admin].*) {
try_files $uri /index.html;
}
}