wilitp 4 лет назад
Родитель
Сommit
693d04a1c0
3 измененных файлов с 41 добавлено и 0 удалено
  1. 3 0
      .dockerignore
  2. 29 0
      Dockerfile.production
  3. 9 0
      nginx.conf

+ 3 - 0
.dockerignore

@@ -0,0 +1,3 @@
+**/node_modules
+**/npm-debug.log
+build

+ 29 - 0
Dockerfile.production

@@ -0,0 +1,29 @@
+
+# Esta imagen es multi-stage, es decir,
+# se buildea en un contenedor transitorio, y luego se hace otro contenedor que sirva la app.
+# Esto para que la imagen sea más liviana y no incluya nada más que el build de producción y nginx
+
+FROM node:14-alpine AS builder
+ENV NODE_ENV production
+# Add a work directory
+WORKDIR /app
+# Cache and Install dependencies
+COPY package.json .
+# COPY package-lock.json .
+RUN npm install --production
+# Copy app files
+COPY . .
+# Build the app
+RUN npm run build
+
+# Bundle static assets with nginx
+FROM nginx:1.21.0-alpine as production
+ENV NODE_ENV production
+# Copy built assets from builder
+COPY --from=builder /app/build /usr/share/nginx/html
+# Add your nginx.conf
+COPY nginx.conf /etc/nginx/conf.d/default.conf
+# Expose port
+EXPOSE 80
+# Start nginx
+CMD ["nginx", "-g", "daemon off;"]

+ 9 - 0
nginx.conf

@@ -0,0 +1,9 @@
+server {
+  listen 80;
+
+  location / {
+    root /usr/share/nginx/html/;
+    include /etc/nginx/mime.types;
+    try_files $uri $uri/ /index.html;
+  }
+}