Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (39 loc) · 1.48 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (39 loc) · 1.48 KB
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
FROM golang:1.16 as builder
ENV APP_USER app
ENV APP_HOME /app
RUN groupadd $APP_USER && useradd -m -g $APP_USER -l $APP_USER
RUN mkdir -p $APP_HOME/build && chown -R $APP_USER:$APP_USER $APP_HOME
WORKDIR $APP_HOME/build
USER $APP_USER
# build master branch
# RUN git clone https://github.com/DNSCrypt/dnscrypt-proxy.git .
# build stable release
# RUN git clone https://github.com/DNSCrypt/dnscrypt-proxy.git . \
# && git checkout tags/2.0.45 -b 2.0.45
# or
RUN git clone --depth 1 -b 2.1.0 https://github.com/DNSCrypt/dnscrypt-proxy.git .
# or
# RUN git clone https://github.com/DNSCrypt/dnscrypt-proxy.git --branch 2.0.46-beta3 .
# build specific commit
# RUN git clone https://github.com/DNSCrypt/dnscrypt-proxy.git . \
# && git checkout 0ca90dd8cc41d1a77c48c28827a42b541e147beb && git reset --hard
WORKDIR $APP_HOME/build/dnscrypt-proxy
# Enable and adjust git commit, when you build specific commit above
# RUN sed -i -E 's/[0-9]{1}.[0-9]{1}.[0-9]{2}-[a-z]{4}[0-9]{1}/&-git-0ca90dd/' main.go
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
RUN go clean \
&& go build -mod vendor -ldflags="-s -w" \
&& cp -p dnscrypt-proxy $APP_HOME/
WORKDIR $APP_HOME
RUN rm -rf build
FROM alpine
ENV APP_HOME /app
WORKDIR $APP_HOME
ENV LOCAL_PORT 53
COPY --chown=0:0 --from=builder $APP_HOME/dnscrypt-proxy $APP_HOME
ADD dnscrypt-proxy.toml /config/dnscrypt-proxy.toml
EXPOSE $LOCAL_PORT/tcp $LOCAL_PORT/udp
ENTRYPOINT ["./dnscrypt-proxy"]
CMD ["-config", "/config/dnscrypt-proxy.toml"]