-
Notifications
You must be signed in to change notification settings - Fork 57
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
debaofu
committed
Sep 10, 2024
1 parent
e8f5533
commit c786180
Showing
3 changed files
with
114 additions
and
1 deletion.
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
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,32 @@ | ||
FROM gplane/pnpm:8.4.0 as builder | ||
ARG SENTRY_AUTH_TOKEN | ||
|
||
WORKDIR /data/web | ||
|
||
COPY pnpm-lock.yaml . | ||
COPY package.json . | ||
|
||
RUN pnpm install | ||
|
||
COPY . . | ||
RUN pnpm run build | ||
|
||
FROM nginx:alpine as nginx | ||
|
||
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | ||
&& echo "Asia/Shanghai" > /etc/timezone | ||
|
||
WORKDIR /data/web | ||
|
||
RUN mkdir -p /app/www | ||
|
||
COPY --from=builder /data/web/dist /app/www | ||
|
||
EXPOSE 80 | ||
EXPOSE 443 | ||
|
||
RUN rm -rf /etc/nginx/conf.d/default.conf | ||
COPY ./nginx/config.sh /root | ||
RUN chmod +x /root/config.sh | ||
|
||
CMD ["/root/config.sh"] |
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,80 @@ | ||
#! /bin/sh -e | ||
|
||
echo "setting environment config" | ||
|
||
cat >> /etc/nginx/conf.d/default.conf <<EOF | ||
map \$http_upgrade \$connection_upgrade { | ||
default upgrade; | ||
'' close; | ||
} | ||
server { | ||
listen 80; | ||
gzip on; | ||
gzip_min_length 1k; | ||
gzip_buffers 4 16k; | ||
#gzip_http_version 1.0; | ||
gzip_comp_level 2; | ||
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; | ||
gzip_vary off; | ||
gzip_disable "MSIE [1-6]."; | ||
proxy_read_timeout 600; | ||
location / { | ||
add_header Access-Control-Allow-Origin *; | ||
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; | ||
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; | ||
if (\$request_filename ~* .*\.(?:htm|html)$) | ||
{ | ||
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate"; | ||
} | ||
root /app/www/; | ||
index index.html; | ||
try_files \$uri \$uri /index.html; | ||
client_max_body_size 500m; | ||
} | ||
location ~* \.js$ { | ||
root /app/www/; | ||
try_files \$uri =404; | ||
} | ||
location ~* \.css$ { | ||
root /app/www/; | ||
try_files \$uri =404; | ||
} | ||
location /api { | ||
proxy_pass $SERVER_URL; | ||
proxy_set_header Host \$host; | ||
proxy_set_header X-Real-IP \$remote_addr; | ||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
} | ||
location /file/ { | ||
proxy_pass $FILE_URL; | ||
proxy_set_header Host \$host; | ||
proxy_set_header X-Real-IP \$remote_addr; | ||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
} | ||
location /ws/ { | ||
proxy_pass $SERVER_URL; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade \$http_upgrade; | ||
proxy_set_header Connection \$connection_upgrade; | ||
proxy_set_header Host \$host; | ||
proxy_set_header X-Real-IP \$remote_addr; | ||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
proxy_set_header REMOTE-HOST \$remote_addr; | ||
} | ||
} | ||
EOF | ||
|
||
echo "starting web server" | ||
|
||
nginx -g 'daemon off;' |