From 54bdb870e6fd71abf1f9b2b848549b928bd47f6c Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Mon, 25 Nov 2019 12:04:02 +0100 Subject: Minify assets (HTML,CSS,JS,JSON,XML,SVG) --- dockerfiles/Dockerfile.bootstrap | 17 +++++++++++++---- dockerfiles/Dockerfile.builder.onbuild | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'dockerfiles') diff --git a/dockerfiles/Dockerfile.bootstrap b/dockerfiles/Dockerfile.bootstrap index 2de4905e..4d9b2d8e 100644 --- a/dockerfiles/Dockerfile.bootstrap +++ b/dockerfiles/Dockerfile.bootstrap @@ -1,8 +1,16 @@ +# +# Build minifier utility +# Adapted from https://github.com/docker/docker.github.io/blob/publish-tools/Dockerfile.builder +# +FROM golang:1.13-alpine AS minifier +RUN apk add --no-cache git +RUN go get -d github.com/tdewolff/minify/cmd/minify \ + && go build -v -o /minify github.com/tdewolff/minify/cmd/minify + # # This is the Nanoc boostrap Dockerfile which builds an image that contains # all Nanoc's runtime dependencies and gems. # - FROM registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-docs # Install packages needed at build and run time @@ -17,9 +25,6 @@ RUN apk add --no-cache libxslt libcurl openssl git grep bash pngquant nodejs # Do not install rdoc to save some space RUN echo 'gem: --no-document' >> /etc/gemrc -# Copy scripts used for static HTML post-processing -COPY scripts /scripts/ - # Copy only Gemfile and Gemfile.lock COPY /Gemfile* /source/ WORKDIR /source @@ -27,4 +32,8 @@ WORKDIR /source # Install gems RUN NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install --jobs 4 +# Copy scripts used for static HTML post-processing +COPY scripts /scripts/ +COPY --from=minifier /minify /scripts/minify + CMD echo "Nothing to do here. This is the bootstrap image that contains all dependencies to build the docs site." diff --git a/dockerfiles/Dockerfile.builder.onbuild b/dockerfiles/Dockerfile.builder.onbuild index 2c5c4fd1..6f72cc53 100644 --- a/dockerfiles/Dockerfile.builder.onbuild +++ b/dockerfiles/Dockerfile.builder.onbuild @@ -28,6 +28,9 @@ ONBUILD RUN /scripts/normalize-links.sh /site ${VER} # Compress images ONBUILD RUN /scripts/compress_images.sh /site ${VER} +# Minify assets +ONBUILD RUN /scripts/minify ${VER} + # Make an index.html and 404.html which will redirect / to /${VER}/ ONBUILD RUN echo "Redirect for ${VER}

If you are not redirected automatically, click here.

" > /site/index.html ONBUILD RUN echo "Redirect for ${VER}

If you are not redirected automatically, click here.

" > /site/404.html -- cgit v1.2.3