diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fda2947 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +# Ignore everything by default +* + +# Allow the public project files. +!src +!public +!Dockerfile +!package*.json +!README.md +!nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1f42a59 --- /dev/null +++ b/Dockerfile @@ -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;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..4bf6e62 --- /dev/null +++ b/nginx.conf @@ -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; + } +}