This commit is contained in:
wayanrivan
2025-05-24 22:48:20 +07:00
2 changed files with 37 additions and 6 deletions

View File

@ -20,20 +20,22 @@ COPY eslint.config.mjs ./eslint.config.mjs
COPY .env.production ./.env.production
COPY .prettierrc ./.prettierrc
COPY index.html ./index.html
COPY vhosts.conf ./vhosts.conf
RUN npm run build:production
FROM node:22-alpine
# FROM node:22-alpine
# Copy node modules and build directory from base image to new image
COPY --from=base ./node_modules ./node_modules
COPY --from=base ./package.json ./package.json
COPY --from=base /dist /dist
COPY --from=base /src /src
COPY --from=base /public /public
# COPY --from=base ./node_modules ./node_modules
# COPY --from=base ./package.json ./package.json
# COPY --from=base /dist /dist
# COPY --from=base /src /src
# COPY --from=base /public /public
# Expose required port
FROM nginx:alpine
COPY --from=base /dist /usr/share/nginx/html
COPY --from=base /vhosts.conf /etc/nginx/conf.d/default.conf
CMD ["nginx", "-g", "daemon off;"]

29
vhosts.conf Normal file
View File

@ -0,0 +1,29 @@
server {
listen 80 default_server;
server_name /usr/share/nginx/html;
root /usr/share/nginx/html;
index index.html index.htm;
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}
location ~* \.(?:css|js|json)$ {
try_files $uri =404;
expires 1y;
access_log off;
add_header Cache-Control "public";
}
# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}
# Any route that doesn't have a file extension (e.g. /devices)
location / {
try_files $uri $uri/ /index.html;
}
}