Improve Dockerfile (#256)
authorC0ffeeCode <ritters_werth@outlook.com>
Sun, 30 Jan 2022 15:28:38 +0000 (16:28 +0100)
committerGitHub <noreply@github.com>
Sun, 30 Jan 2022 15:28:38 +0000 (20:58 +0530)
* Use npm ci over install to achive faster and more expectable build results;
Split copy package(-lock).json files and ci then to avoid reinstalling dependencies when not needed => Faster build times

* Stopp adding wasm type to mime.types, its already there (duplicate):
- avoids warning in console
- cleans up
- might have been missing in past nginx:alpine versions but now exists

* Change node tag from alpine and nginx to more specific ones for #260

.dockerignore [new file with mode: 0644]
Dockerfile

diff --git a/.dockerignore b/.dockerignore
new file mode 100644 (file)
index 0000000..be0443a
--- /dev/null
@@ -0,0 +1,2 @@
+node_modules/
+.git/
index 306400341ef4f202a420bd4368315905ff3b34bb..751e1e88ecc857bfc6fb21d560db5cefaf7b3a89 100644 (file)
@@ -1,20 +1,18 @@
 ## Builder
-FROM node:14-alpine as builder
+FROM node:17.4.0-alpine3.15 as builder
 
 WORKDIR /src
 
+COPY package.json package-lock.json /src
+RUN npm ci
 COPY . /src
-RUN npm install \
-  && npm run build
+RUN npm run build
 
 
 ## App
-FROM nginx:alpine
+FROM nginx:1.21.6-alpine
 
 COPY --from=builder /src/dist /app
 
-# Insert wasm type into Nginx mime.types file so they load correctly.
-RUN sed -i '3i\ \ \ \ application/wasm wasm\;' /etc/nginx/mime.types
-
 RUN rm -rf /usr/share/nginx/html \
   && ln -s /app /usr/share/nginx/html