Skip to content

Instantly share code, notes, and snippets.

@cooperaj
Created Aug 13, 2018
Embed
What would you like to do?
Hugo docker build
# Build stage
FROM node:8 as build
ENV HUGO_VERSION 0.45
# Install dependencies
RUN apt-get update && apt-get install -y \
nasm && \
curl -sLo hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz" && \
mkdir hugo && \
tar xzf hugo.tar.gz -C hugo/ && \
rm -r hugo.tar.gz && \
mv hugo/hugo /usr/bin/hugo && \
rm -r hugo/
# Install asset building dependencies
COPY .npmrc themes/theme/package.json themes/theme/package-lock.json /build/themes/theme/
RUN cd /build/themes/theme && npm i
# Build site
COPY . /build
RUN cd /build/themes/theme && \
npm run production && \
cd /build && \
hugo
# Runtime stage
FROM nginx:mainline-alpine
WORKDIR /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /build/public/. .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment