Added Dockerfile.

This commit is contained in:
moonstar-x 2023-06-02 13:58:56 -05:00
parent 9563a5f2c0
commit a21710d624
3 changed files with 43 additions and 0 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
# Ignore everything by default
*
# Allow the public project files.
!src
!public
!Dockerfile
!package*.json
!README.md
!nginx.conf

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM node:16.6.1-alpine AS builder
WORKDIR /tmp
COPY package*.json ./
RUN npm ci --only=prod
COPY . .
ENV NODE_ENV=production
RUN npm run build
FROM nginx:alpine
COPY --from=builder /tmp/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
RUN touch /var/run/nginx.pid
RUN chown -R nginx:nginx /var/run/nginx.pid /usr/share/nginx/html /var/cache/nginx /var/log/nginx /etc/nginx/conf.d
USER nginx
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]

10
nginx.conf Normal file
View File

@ -0,0 +1,10 @@
server_tokens off;
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
}
}