Skip to content

Instantly share code, notes, and snippets.

@cooperaj
Created August 13, 2018 13:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cooperaj/7ce93a4a81857c76de913c086eaea15e to your computer and use it in GitHub Desktop.
Save cooperaj/7ce93a4a81857c76de913c086eaea15e to your computer and use it in GitHub Desktop.
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