-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
75 lines (50 loc) · 1.57 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
FROM --platform=${BUILDOS}/${BUILDARCH} golang:alpine AS builder
WORKDIR /build
RUN apk add gcc musl-dev
COPY go* *.go /build/
COPY static static
COPY parser parser
COPY style style
COPY utils utils
COPY config config
RUN GOOS=linux GOARCH=arm64 go build -trimpath -o rss-banquet-linux-arm64
RUN GOOS=linux GOARCH=amd64 go build -trimpath -o rss-banquet-linux-amd64
# Base
FROM --platform=${TARGETOS}/${TARGETARCH} alpine:latest AS base
ARG TARGETARCH
ARG TARGETOS
COPY --from=builder /build/rss-banquet-${TARGETOS}-${TARGETARCH} /usr/bin/rss-banquet
# Server
FROM base AS server
ENV PORT=8080
ENV GIN_MODE=release
EXPOSE ${PORT}
CMD rss-banquet server -p ${PORT}
# Development
FROM builder AS dev-server
ENV PORT=8080
ENV GIN_MODE=debug
EXPOSE ${PORT}
RUN apk update && apk add watchexec
CMD ["watchexec", "-w", ".", "-e", "go,sum,mod", "-r", "sh", "-c", "date && echo [WATCHEXEC] Building... && go build && echo [WATCHEXEC] Built, launching && ./rss-banquet server -p ${PORT}"]
# nginx
FROM base AS nginx
ENV PORT=8080
ENV GIN_MODE=release
EXPOSE ${PORT}
RUN apk update && apk add nginx && rm -rf /var/cache/apk/*
RUN cat <<EOF > /etc/nginx/http.d/default.conf
proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=mycache:50m max_size=1g inactive=15m use_temp_path=off;
gzip on;
gzip_types application/json application/rss+xml application/atom+xml;
server {
listen ${PORT};
proxy_cache mycache;
location / {
proxy_pass http://localhost:8081;
proxy_cache_valid 200 15m;
proxy_cache_lock on;
}
}
EOF
CMD ["sh", "-c", "nginx && rss-banquet server -p 8081"]