forked from apernet/hysteria
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
48 lines (36 loc) · 1.52 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
FROM golang:alpine AS builder
LABEL maintainer="mritd <[email protected]>"
# GOPROXY is disabled by default, use:
# docker build --build-arg GOPROXY="https://goproxy.io" ...
# to enable GOPROXY.
ARG GOPROXY=""
ENV GOPROXY ${GOPROXY}
COPY . /go/src/github.com/hynetwork/hysteria
WORKDIR /go/src/github.com/hynetwork/hysteria/cmd
RUN set -ex \
&& apk add git build-base \
&& export VERSION=$(git describe --tags) \
&& export COMMIT=$(git rev-parse HEAD) \
&& export TIMESTAMP=$(date "+%F %T") \
&& go build -o /go/bin/hysteria -ldflags \
"-w -s -X 'main.appVersion=${VERSION}' \
-X 'main.appCommit=${COMMIT}' \
-X 'main.appDate=${TIMESTAMP}'"
# multi-stage builds to create the final image
FROM alpine AS dist
LABEL maintainer="mritd <[email protected]>"
# set up nsswitch.conf for Go's "netgo" implementation
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
# bash is used for debugging, tzdata is used to add timezone information.
# Install ca-certificates to ensure no CA certificate errors.
#
# Do not try to add the "--no-cache" option when there are multiple "apk"
# commands, this will cause the build process to become very slow.
RUN set -ex \
&& apk upgrade \
&& apk add bash tzdata ca-certificates \
&& rm -rf /var/cache/apk/*
COPY --from=builder /go/bin/hysteria /usr/local/bin/hysteria
ENTRYPOINT ["hysteria"]