Simplified Dockerfile using multi-stage build

This commit is contained in:
Alejandro Celaya 2019-03-03 10:12:59 +01:00
parent 98725dce04
commit 2c6dbb42c1
2 changed files with 7 additions and 19 deletions

View file

@ -1,4 +1,5 @@
./build ./build
./coverage
./dist ./dist
./node_modules ./node_modules
./test ./test

View file

@ -1,21 +1,8 @@
FROM node:10.15.2 as node
COPY . /shlink-web-client
RUN cd /shlink-web-client && yarn install && yarn build
FROM nginx:1.15.9-alpine FROM nginx:1.15.9-alpine
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>" LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
RUN rm -r /usr/share/nginx/html
# Install node and yarn COPY --from=node /shlink-web-client/build /usr/share/nginx/html
RUN apk add --no-cache nodejs && apk add --no-cache yarn
ADD . ./shlink-web-client
# Install dependencies and build project
RUN cd ./shlink-web-client && \
yarn install && \
yarn build && \
# Move build contents to document root
cd .. && \
rm -r /usr/share/nginx/html/* && \
mv ./shlink-web-client/build/* /usr/share/nginx/html && \
rm -r ./shlink-web-client && \
# Delete and uninstall build tools
yarn cache clean && apk del yarn && apk del nodejs