Skip to content

Commit c8b6e21

Browse files
committed
add Dockerfile and Caddyfile for caddy server
1 parent c8db7ca commit c8b6e21

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

Caddyfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
0.0.0.0
2+
3+
browse
4+
5+
log stdout
6+
errors stdout
7+
8+
root /srv/openpitrix.github.io/public
9+
hugo /srv/openpitrix.github.io
10+
11+
gopkg /openpitrix https://github.com/openpitrix/openpitrix
12+
13+
git {
14+
path /srv/openpitrix.github.io
15+
repo https://github.com/openpitrix/openpitrix.github.io.git
16+
then hugo --destination=/srv/openpitrix.github.io/public
17+
interval 5
18+
}

Dockerfile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# Builder
3+
#
4+
FROM golang:1.9-alpine as builder
5+
6+
ARG version="0.10.10"
7+
ARG plugins="git gopkg hugo"
8+
9+
RUN apk add --no-cache curl git hugo
10+
11+
# caddy
12+
RUN git clone https://github.com/mholt/caddy -b "v${version}" /go/src/github.com/mholt/caddy \
13+
&& cd /go/src/github.com/mholt/caddy \
14+
&& git checkout -b "v${version}"
15+
16+
# plugin helper
17+
RUN go get -v github.com/abiosoft/caddyplug/caddyplug
18+
19+
# plugins
20+
RUN for plugin in $(echo $plugins | tr "," " "); do \
21+
go get -v $(caddyplug package $plugin); \
22+
printf "package caddyhttp\nimport _ \"$(caddyplug package $plugin)\"" > \
23+
/go/src/github.com/mholt/caddy/caddyhttp/$plugin.go ; \
24+
done
25+
26+
# builder dependency
27+
RUN git clone https://github.com/caddyserver/builds /go/src/github.com/caddyserver/builds
28+
29+
# build
30+
RUN cd /go/src/github.com/mholt/caddy/caddy \
31+
&& git checkout -f \
32+
&& go run build.go \
33+
&& mv caddy /go/bin
34+
35+
#
36+
# Final stage
37+
#
38+
FROM alpine:3.6
39+
LABEL caddy_version="0.10.10"
40+
41+
RUN apk add --no-cache openssh-client git hugo
42+
43+
# install caddy
44+
COPY --from=builder /go/bin/caddy /usr/bin/caddy
45+
46+
# validate install
47+
RUN /usr/bin/caddy -version
48+
RUN /usr/bin/caddy -plugins
49+
50+
EXPOSE 80 443 2015
51+
VOLUME /root/.caddy /srv
52+
WORKDIR /srv
53+
54+
COPY Caddyfile /etc/Caddyfile
55+
COPY index.html /srv/index.html
56+
57+
ENTRYPOINT ["/usr/bin/caddy"]
58+
CMD ["--conf", "/etc/Caddyfile", "--log", "stdout"]

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
default:
2-
hugo new site openpitrix.io
32

3+
run:
4+
docker run --rm -it -p 2015:2015 -v `pwd`/Caddyfile:/etc/Caddyfile chai2010/caddy-docker
5+
6+
clean:

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello https://openpitrix.io

0 commit comments

Comments
 (0)