diff --git a/Dockerfile b/Dockerfile index e91f893..308b894 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,45 +1,30 @@ -# GitHub: https://github.com/gohugoio -# Twitter: https://twitter.com/gohugoio -# Website: https://gohugo.io/ +FROM alpine:latest as builder -FROM golang:1.16-alpine AS build +# Hugo versions +ENV HUGO_VERSION 0.88.1 +ENV HUGO_BINARY hugo_${HUGO_VERSION}_linux-64bit -# Optionally set HUGO_BUILD_TAGS to "extended" or "nodeploy" when building like so: -# docker build --build-arg HUGO_BUILD_TAGS=extended . -ARG HUGO_BUILD_TAGS +# Install pygments for code highlighting +RUN apk update && apk add py-pygments && apk add bash && rm -rf /var/cache/apk/* -ARG CGO=1 -ENV CGO_ENABLED=${CGO} -ENV GOOS=linux -ENV GO111MODULE=on +# Install Hugo +RUN mkdir /usr/local/hugo +ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY}.tar.gz /usr/local/hugo/ +RUN tar xzf /usr/local/hugo/${HUGO_BINARY}.tar.gz -C /usr/local/hugo/ \ + && ln -s /usr/local/hugo/hugo /usr/local/bin/hugo \ + && rm /usr/local/hugo/${HUGO_BINARY}.tar.gz -WORKDIR /drone/src/blog/blog/ +# Copy hugo site +WORKDIR /app +COPY site/ /app -COPY . /drone/src/blog/blog/ +# Build site +RUN hugo --minify --enableGitInfo --gc -d /app/build -# gcc/g++ are required to build SASS libraries for extended version -RUN apk update && \ - apk add --no-cache gcc g++ musl-dev && \ - go get github.com/magefile/mage -RUN mage hugo && mage install +# Create the webserver +FROM nginx:latest -# --- - -FROM alpine:3.12 - -COPY --from=build /go/bin/hugo /usr/bin/hugo - -# libc6-compat & libstdc++ are required for extended SASS libraries -# ca-certificates are required to fetch outside resources (like Twitter oEmbeds) -RUN apk update && \ - apk add --no-cache ca-certificates libc6-compat libstdc++ git - -VOLUME /site -WORKDIR /site - -# Expose port for live server -EXPOSE 1313 - -ENTRYPOINT ["hugo"] -CMD ["--help"] \ No newline at end of file +# Copy built files +COPY --from=builder /app/build /usr/share/nginx/html +EXPOSE 80 \ No newline at end of file