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
./coverage
./dist
./node_modules
./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
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
# Install node and yarn
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
RUN rm -r /usr/share/nginx/html
COPY --from=node /shlink-web-client/build /usr/share/nginx/html