Soleilw 7 months ago
parent
commit
77c4e8fb95
5 changed files with 100 additions and 1 deletions
  1. 4
    1
      .gitignore
  2. 28
    0
      Dockerfile
  3. 54
    0
      default-nginx.conf
  4. 7
    0
      docker-compose-test.yml
  5. 7
    0
      docker-compose.yml

+ 4
- 1
.gitignore View File

@@ -1,2 +1,5 @@
node_modules

.vscode
p
readme-admin.md
dc-rcsc-admin.yaml

+ 28
- 0
Dockerfile View File

@@ -0,0 +1,28 @@
# 使用 Node 作为基础镜像
FROM registry.cn-hangzhou.aliyuncs.com/zsanyu/rcsc:amd64-node-21 as builder

# 设置工作目录
WORKDIR /app

# 拷贝package.json和package-lock.json
COPY package*.json ./

# 安装依赖
RUN npm config set registry https://registry.npmmirror.com && \
npm install

# 将项目文件拷贝到工作目录
COPY . .

# 构建项目
RUN npx vite build

FROM nginx:stable-alpine

RUN rm -rf /etc/nginx/conf.d/default.conf

COPY --from=builder /app/dist /usr/share/nginx/html
COPY --from=builder /app/default-nginx.conf /etc/nginx/conf.d/default.conf

# 暴露端口
EXPOSE 80

+ 54
- 0
default-nginx.conf View File

@@ -0,0 +1,54 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

# location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
# }

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ @rewrites;
}

location @rewrites {
rewrite ^(.+)$ /index.html last;
}
#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


+ 7
- 0
docker-compose-test.yml View File

@@ -0,0 +1,7 @@
version: "3.3"
services:
api:
build:
context: .
dockerfile: ./Dockerfile
image: registry.cn-hangzhou.aliyuncs.com/zsanyu/rcsc:rcsc_admin_test_latest

+ 7
- 0
docker-compose.yml View File

@@ -0,0 +1,7 @@
version: "3.3"
services:
api:
build:
context: .
dockerfile: ./Dockerfile
image: registry.cn-hangzhou.aliyuncs.com/zsanyu/rcsc:rcsc_admin_prod_latest

Loading…
Cancel
Save