Skip to content

Commit

Permalink
feat: nginx template
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinse committed Dec 12, 2024
1 parent a210569 commit c109fb8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
RUN pnpm run build

FROM nginx:alpine
ARG API_URL

COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
RUN sed -i "s#_API_URL_#${API_URL}#g" /etc/nginx/conf.d/default.conf
COPY docker/templates /etc/nginx/templates
# RUN sed -i "s#_API_URL_#${API_URL}#g" /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /app/dist
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# EXPOSE 80
# CMD ["nginx", "-g", "daemon off;"]
26 changes: 26 additions & 0 deletions docker/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
server {
listen 80;
server_name ${SERVER_NAME};
# Set the maximum allowed size of the client request body
client_max_body_size 1G;

location / {
root /app/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

location /api/ {
proxy_pass ${API_URL};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

0 comments on commit c109fb8

Please sign in to comment.