jxruoa
Last Updated: September 19, 2016
·
519
· asuna

HUGO for gitlab pages

Here is dockerfile what i using on gitlab runner to update my page (made with hugo v 0.16).

FROM debian:wheezy

# Install pygments (for syntax highlighting) 
RUN apt-get -qq update \
    && DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends python-pygments \
    && rm -rf /var/lib/apt/lists/*

# Download and install hugo
ENV HUGO_VERSION 0.16
ENV HUGO_BINARY hugo_${HUGO_VERSION}_linux-64bit

ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY}.tgz /usr/local/
RUN tar xzf /usr/local/${HUGO_BINARY}.tgz -C /usr/local/ \
    && ln -s /usr/local/hugo /usr/local/bin/hugo \
    && rm /usr/local/${HUGO_BINARY}.tgz

# Create working directory
RUN mkdir /usr/share/blog
WORKDIR /usr/share/blog

# Expose default hugo port
EXPOSE 1313

# Automatically build site
ONBUILD ADD site/ /usr/share/blog
ONBUILD RUN hugo -d /usr/share/nginx/html/

# By default, serve site
ENV HUGO_BASE_URL http://localhost:1313
CMD hugo server -b ${HUGO_BASE_URL}

To build run docker build -t my/image . from same folder where is your Dockerfile and add this to image: in your gitlab ci config.