Get all the bits in place to do docker-based build, generation, linting, and serving of the site.

This commit is contained in:
mtail 2018-06-14 17:20:19 -07:00
parent 9720690df7
commit f8a5265efa
8 changed files with 101 additions and 30 deletions

28
.circleci/config.yml Normal file
View File

@ -0,0 +1,28 @@
version: 2
jobs:
build:
docker:
- image: gcr.io/istio-testing/website-builder:2018-06-15
working_directory: ~/site
steps:
- checkout
- run:
name: Generating Site
command: scripts/gen_site.sh ""
- restore_cache:
keys:
- htmlproofer-cache-v4
- run:
name: Running Linters
command: scripts/lint_site.sh
# save the external URLs cache
- save_cache:
key: htmlproofer-cache-v4
paths:
- .htmlproofer

View File

@ -1,30 +0,0 @@
FROM alpine:latest
RUN apk add --no-cache \
nodejs \
ruby \
ruby-dev \
hugo \
build-base \
gcc \
libc-dev \
zlib-dev \
libxslt-dev \
libxml2-dev \
git && \
apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted gnu-libiconv
RUN npm install -g \
html-minifier \
sass \
uglify-js \
markdown-spellcheck
RUN gem install --no-ri --no-rdoc \
mdl \
html-proofer
ENV PATH /usr/bin:$PATH
# TODO: replace with your ENTRYPOINT or CMD.
CMD [ "/usr/bin/ruby", "-v"]

42
scripts/Dockerfile Normal file
View File

@ -0,0 +1,42 @@
FROM ruby:2.4-alpine
RUN echo 'gem: --no-document' >> /etc/gemrc
RUN apk add --no-cache \
nodejs \
ruby \
ruby-dev \
build-base \
gcc \
libc-dev \
zlib-dev \
libxslt-dev \
libxml2-dev \
libcurl \
git \
&& apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted gnu-libiconv
ENV HUGO_VERSION=0.42.1
ADD https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz /tmp
RUN tar -xf /tmp/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz -C /tmp \
&& mkdir -p /usr/local/sbin \
&& mv /tmp/hugo /usr/local/sbin/hugo \
&& rm -rf /tmp/hugo_${HUGO_VERSION}_linux_amd64 \
&& rm -rf /tmp/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz \
&& rm -rf /tmp/LICENSE.md \
&& rm -rf /tmp/README.md
RUN npm install -g \
html-minifier \
sass \
uglify-js \
markdown-spellcheck
RUN gem install \
mdl \
html-proofer
ENV PATH /usr/bin:$PATH
# TODO: replace with your ENTRYPOINT or CMD.
CMD [ "/usr/bin/ruby", "-v"]

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
HUB=gcr.io/istio-testing
VERSION=$(date +%Y-%m-%d)
docker build --no-cache -t $HUB/website-builder:$VERSION .
gcloud docker -- push $HUB/website-builder:$VERSION

12
scripts/build_site.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env sh
sass src/sass/light_theme_archive.scss light_theme_archive.css -s compressed
sass src/sass/light_theme_normal.scss light_theme_normal.css -s compressed
sass src/sass/light_theme_preliminary.scss light_theme_preliminary.css -s compressed
sass src/sass/dark_theme_archive.scss dark_theme_archive.css -s compressed
sass src/sass/dark_theme_normal.scss dark_theme_normal.css -s compressed
sass src/sass/dark_theme_preliminary.scss dark_theme_preliminary.css -s compressed
mv light_theme* static/css
mv dark_theme* static/css
uglifyjs src/js/misc.js src/js/prism.js --mangle --compress -o static/js/all.min.js --source-map
uglifyjs src/js/styleSwitcher.js --mangle --compress -o static/js/styleSwitcher.min.js --source-map

4
scripts/gen_site.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
hugo --baseURL "$1"
html-minifier --input-dir public --output-dir public --file-ext html --collapse-whitespace --minify-js --minify-css --sort-attributes --sort-class-name --remove-attribute-quotes --remove-comments

5
scripts/lint_site.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env sh
mdspell --en-us --ignore-acronyms --ignore-numbers --no-suggestions --report content/*.md content/*/*.md content/*/*/*.md content/*/*/*/*.md content/*/*/*/*/*.md content/*/*/*/*/*/*.md content/*/*/*/*/*/*/*.md
mdl --ignore-front-matter --style mdl_style.rb .
htmlproofer ./public --check-html --assume-extension --timeframe 2d --storage-dir .htmlproofer --url-ignore "/localhost/,/github.com/istio/istio.github.io/edit/master/,/github.com/istio/istio/issues/new/choose/"

3
scripts/serve_site.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
hugo serve --disableFastRender