mirror of
https://github.com/alexohneander/alexohneander-astro.git
synced 2025-06-28 14:31:52 +00:00
feat: use nginx as server
This commit is contained in:
parent
af92b228e6
commit
09d6e1e9a0
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
dist
|
26
Dockerfile
26
Dockerfile
@ -1,25 +1,11 @@
|
||||
FROM node:lts AS base
|
||||
FROM node:lts AS build
|
||||
WORKDIR /app
|
||||
|
||||
# By copying only the package.json and package-lock.json here, we ensure that the following `-deps` steps are independent of the source code.
|
||||
# Therefore, the `-deps` steps will be skipped if only the source code changes.
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
FROM base AS prod-deps
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
FROM base AS build-deps
|
||||
RUN npm install
|
||||
|
||||
FROM build-deps AS build
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM base AS runtime
|
||||
COPY --from=prod-deps /app/node_modules ./node_modules
|
||||
COPY --from=build /app/dist ./dist
|
||||
|
||||
ENV HOST=0.0.0.0
|
||||
ENV PORT=4321
|
||||
EXPOSE 4321
|
||||
CMD node ./dist/server/entry.mjs
|
||||
FROM nginx:alpine AS runtime
|
||||
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
EXPOSE 8080
|
@ -38,7 +38,7 @@ securityContext: {}
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 4321
|
||||
port: 8080
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
|
31
nginx/nginx.conf
Normal file
31
nginx/nginx.conf
Normal file
@ -0,0 +1,31 @@
|
||||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
include /etc/nginx/mime.types;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1000;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /404.html {
|
||||
root /usr/share/nginx/html;
|
||||
internal;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/index.html =404;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user