diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2020-07-08 16:10:07 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2020-07-08 16:50:26 +0300 |
commit | 3380644f843714d9e3e3912c605ec8eddb039ae6 (patch) | |
tree | a2fc5d10617d2044c22d0266d86a8b6f55c99f59 | |
parent | 1223670d0ada4534b1e8b60c7607a32f2197b9ac (diff) |
Do not hardcode the path of the minify binary
Make it so minify-assets.sh can also be run locally.
-rw-r--r-- | dockerfiles/Dockerfile.bootstrap | 2 | ||||
-rwxr-xr-x | scripts/minify-assets.sh | 25 |
2 files changed, 22 insertions, 5 deletions
diff --git a/dockerfiles/Dockerfile.bootstrap b/dockerfiles/Dockerfile.bootstrap index d65697b0..9dfdd857 100644 --- a/dockerfiles/Dockerfile.bootstrap +++ b/dockerfiles/Dockerfile.bootstrap @@ -28,7 +28,7 @@ RUN yarn install # Copy scripts used for static HTML post-processing COPY scripts /scripts/ -COPY --from=minifier /minify /scripts/minify +COPY --from=minifier /minify /usr/local/bin/minify MAINTAINER GitLab Documentation Team diff --git a/scripts/minify-assets.sh b/scripts/minify-assets.sh index a0b5bfb7..7da94bf9 100755 --- a/scripts/minify-assets.sh +++ b/scripts/minify-assets.sh @@ -15,12 +15,29 @@ if ! [ -d "$TARGET" ]; then exit 1 fi +# Check if minify is in the PATH +which minify > /dev/null 2>&1 +# Check if the previous command has a 0 exit status +if [ $? -eq 0 ] +then + MINIFY_BIN=$(which minify) +else + # Backwards compatibility + if [ -f /scripts/minify ] + then + MINIFY_BIN=/scripts/minify + else + echo "minify binary not found in PATH. Exiting." + exit 1 + fi +fi + # Minify assets printf "Optimizing assets..." -printf "HTML..."; /scripts/minify $MINIFY_FLAGS --type=html --match=\.html -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true -printf "CSS..." ; /scripts/minify $MINIFY_FLAGS --type=css --match=\.css -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true -printf "JSON..."; /scripts/minify $MINIFY_FLAGS --type=json --match=\.json -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true -printf "SVG..." ; /scripts/minify $MINIFY_FLAGS --type=svg --match=\.svg -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true +printf "HTML..."; $MINIFY_BIN $MINIFY_FLAGS --type=html --match=\.html -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true +printf "CSS..." ; $MINIFY_BIN $MINIFY_FLAGS --type=css --match=\.css -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true +printf "JSON..."; $MINIFY_BIN $MINIFY_FLAGS --type=json --match=\.json -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true +printf "SVG..." ; $MINIFY_BIN $MINIFY_FLAGS --type=svg --match=\.svg -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true echo "Done" |