This commit is contained in:
Newnius 2019-11-23 20:28:15 +08:00
parent b677d7f0da
commit e9b0ca3b9b
3 changed files with 66 additions and 0 deletions

39
hugo/Dockerfile Normal file
View File

@ -0,0 +1,39 @@
FROM golang:1.13-alpine AS build
MAINTAINER Newnius <newnius.cn@gmail.com>
# Optionally set HUGO_BUILD_TAGS to "extended" when building like so:
# docker build --build-arg HUGO_BUILD_TAGS=extended .
ARG HUGO_BUILD_TAGS
ARG CGO=1
ENV CGO_ENABLED=${CGO}
ENV GOOS=linux
ENV GO111MODULE=on
RUN apk add --no-cache git
RUN git clone https://github.com/gohugoio/hugo.git /hugo
RUN cd /hugo
RUN go install
# ---
FROM alpine:3.10
MAINTAINER Newnius <newnius.cn@gmail.com>
COPY --from=build /go/bin/hugo /usr/bin/hugo
ADD bootstrap.sh /etc/bootstrap.sh
WORKDIR /blog
# Expose port for live server
EXPOSE 1313
ENTRYPOINT ["/etc/bootstrap.sh"]

19
hugo/README.md Normal file
View File

@ -0,0 +1,19 @@
# Dockered Hugo
## What is `Hugo`
> Hugo is a static HTML and CSS website generator written in Go. It is optimized for speed, ease of use, and configurability. Hugo takes a directory with content and templates and renders them into a full HTML website.
Documents: [Hugo](https://gohugo.io/)
```
docker run \
--name hugo \
-d \
--restart always \
--hostname hugo \
-p 1313:1313 \
--mount type=bind,source=/path/to/blog,target=/blog \
newnius/hugo
```

8
hugo/bootstrap.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
# init hugo if dir is empty
if ! [ "$(ls -A /blog )" ]; then
hugo new site /blog
fi
hugo server --bind 0.0.0.0