Improved building process so that already generated dist files are reused when building docker image is possible

This commit is contained in:
Alejandro Celaya 2020-03-20 09:12:43 +01:00
parent 38fc402b16
commit b5a188e802
3 changed files with 8 additions and 3 deletions

View file

@ -1,7 +1,6 @@
./.github
./build
./coverage
./dist
./node_modules
./test
./shlink-web-client.gif

View file

@ -28,7 +28,7 @@ after_success:
# Before deploying, build dist file for current travis tag
before_deploy:
- npm run build ${TRAVIS_TAG#?}
- if [[ ! -z $TRAVIS_TAG ]]; then npm run build ${TRAVIS_TAG#?} ; fi
deploy:
- provider: script

View file

@ -2,7 +2,13 @@ FROM node:12.14.1-alpine as node
COPY . /shlink-web-client
ARG VERSION="latest"
ENV VERSION ${VERSION}
RUN cd /shlink-web-client && npm install && npm run build -- ${VERSION} --no-dist
RUN cd /shlink-web-client && \
UNCOMPRESSED="shlink-web-client_${VERSION}_dist" && \
DIST_FILE="./dist/${UNCOMPRESSED}.zip" && \
# If a dist file already exists, just unzip it
if [[ -f ${DIST_FILE} ]]; then unzip ${DIST_FILE} && mv ./${UNCOMPRESSED} ./build ; fi && \
# If no dist file exsts, build from scratch
if [[ ! -f ${DIST_FILE} ]]; then npm install && npm run build -- ${VERSION} --no-dist ; fi
FROM nginx:1.17.7-alpine
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"