From 3ae7948aec06465c85cde65fce653e95945b3b86 Mon Sep 17 00:00:00 2001 From: jeff Date: Fri, 10 Apr 2020 23:56:57 +0000 Subject: [PATCH] AddDockerfiles (#9) Add dockerfile for dev. Add dockerfile for prod deploy. Co-authored-by: russoj88 Reviewed-by: steverusso --- Dockerfile.dev | 11 +++++++++++ Dockerfile.prod | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Dockerfile.dev create mode 100644 Dockerfile.prod diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..259b716 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,11 @@ +FROM golang:alpine + +# This should be mounted with docker run command +WORKDIR /src + +# Build and run hugo +ENV GO111MODULE=on +RUN go get -u github.com/gohugoio/hugo@v0.69.0 + +# Run the development server +ENTRYPOINT cd /src && hugo server diff --git a/Dockerfile.prod b/Dockerfile.prod new file mode 100644 index 0000000..35c832d --- /dev/null +++ b/Dockerfile.prod @@ -0,0 +1,34 @@ +# STEP 1: Build the website's files +FROM golang:alpine AS build-website + +WORKDIR /src + +COPY . /src/ + +RUN cd /src + +ENV GO111MODULE=on +RUN go get -u github.com/gohugoio/hugo@v0.69.0 + +RUN hugo --minify + +# STEP 2: Get a binary for the static-web-server +FROM golang:alpine AS build-webserver + +RUN apk update && apk upgrade && \ + apk add --no-cache git + +RUN go get -u git.simplesystems.tech/SimpleSystems/static-web-server + +# STEP 3: Combine static files and binary on fresh alpine image +FROM alpine:latest + +WORKDIR /app + +# Copy over static website files +COPY --from=build-website /src/public /app/public + +# Copy over static-web-server +COPY --from=build-webserver /go/bin/static-web-server /app/ + +ENTRYPOINT ["./static-web-server", "-rootDir", "public", "-port", "80", "-redirect"]