mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2024-11-22 12:47:27 +08:00
refactor(dockerfile): separate nginx config from Dockerfile
This commit is contained in:
parent
70d2713643
commit
99371def54
29
Dockerfile
29
Dockerfile
|
@ -8,34 +8,6 @@ COPY . .
|
|||
RUN yarn build
|
||||
|
||||
FROM nginx:1.20.2-alpine as app
|
||||
RUN echo $'server { \n\
|
||||
gzip on;\n\
|
||||
listen 80; \n\
|
||||
listen [::]:80; \n\
|
||||
server_name localhost; \n\
|
||||
\n\
|
||||
location / { \n\
|
||||
root /usr/share/nginx/html; \n\
|
||||
index index.html; \n\
|
||||
try_files $uri $uri/ /index.html; \n\
|
||||
} \n\
|
||||
\n\
|
||||
location @rewrites { \n\
|
||||
rewrite ^(.*)$ /index.html last; \n\
|
||||
} \n\
|
||||
\n\
|
||||
location /api/ { \n\
|
||||
proxy_buffer_size 128k; \n\
|
||||
proxy_buffers 16 32k; \n\
|
||||
proxy_busy_buffers_size 128k; \n\
|
||||
proxy_set_header Host $host; \n\
|
||||
proxy_set_header X-Real-IP $remote_addr; \n\
|
||||
proxy_set_header X-Forwarded-For $remote_addr; \n\
|
||||
proxy_set_header X-Forwarded-Host $remote_addr; \n\
|
||||
proxy_set_header X-NginX-Proxy true; \n\
|
||||
proxy_pass http://localhost:3000/; \n\
|
||||
} \n\
|
||||
}' > /etc/nginx/conf.d/default.conf
|
||||
|
||||
COPY --from=build /app/package.json /usr/local/lib/
|
||||
|
||||
|
@ -44,6 +16,7 @@ RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.14/m
|
|||
&& npm i -g $(awk -F \" '{if($2=="NeteaseCloudMusicApi") print $2"@"$4}' /usr/local/lib/package.json) \
|
||||
&& rm -f /usr/local/lib/package.json
|
||||
|
||||
COPY --from=build /app/docker/nginx.conf.example /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
CMD nginx ; exec npx NeteaseCloudMusicApi
|
||||
|
|
28
docker/nginx.conf.example
Normal file
28
docker/nginx.conf.example
Normal file
|
@ -0,0 +1,28 @@
|
|||
server {
|
||||
gzip on;
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location @rewrites {
|
||||
rewrite ^(.*)$ /index.html last;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_buffers 16 32k;
|
||||
proxy_buffer_size 128k;
|
||||
proxy_busy_buffers_size 128k;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Host $remote_addr;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_pass http://localhost:3000/;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user