94 lines
2.8 KiB
Docker
94 lines
2.8 KiB
Docker
FROM alpine:3.7
|
|
|
|
RUN apk add --no-cache \
|
|
ca-certificates
|
|
|
|
# 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
|
|
|
|
ENV GOLANG_VERSION 1.11
|
|
|
|
RUN set -eux; \
|
|
apk add --no-cache --virtual .build-deps \
|
|
bash \
|
|
gcc \
|
|
musl-dev \
|
|
openssl \
|
|
go \
|
|
; \
|
|
export \
|
|
# set GOROOT_BOOTSTRAP such that we can actually build Go
|
|
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
|
|
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
|
|
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
|
|
GOOS="$(go env GOOS)" \
|
|
GOARCH="$(go env GOARCH)" \
|
|
GOHOSTOS="$(go env GOHOSTOS)" \
|
|
GOHOSTARCH="$(go env GOHOSTARCH)" \
|
|
; \
|
|
# also explicitly set GO386 and GOARM if appropriate
|
|
# https://github.com/docker-library/golang/issues/184
|
|
apkArch="$(apk --print-arch)"; \
|
|
case "$apkArch" in \
|
|
armhf) export GOARM='6' ;; \
|
|
x86) export GO386='387' ;; \
|
|
esac; \
|
|
\
|
|
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
|
|
echo 'afc1e12f5fe49a471e3aae7d906c73e9d5b1fdd36d52d72652dde8f6250152fb *go.tgz' | sha256sum -c -; \
|
|
tar -C /usr/local -xzf go.tgz; \
|
|
rm go.tgz; \
|
|
\
|
|
cd /usr/local/go/src; \
|
|
./make.bash; \
|
|
\
|
|
rm -rf \
|
|
# https://github.com/golang/go/blob/0b30cf534a03618162d3015c8705dd2231e34703/src/cmd/dist/buildtool.go#L121-L125
|
|
/usr/local/go/pkg/bootstrap \
|
|
# https://golang.org/cl/82095
|
|
# https://github.com/golang/build/blob/e3fe1605c30f6a3fd136b561569933312ede8782/cmd/release/releaselet.go#L56
|
|
/usr/local/go/pkg/obj \
|
|
; \
|
|
apk del .build-deps; \
|
|
\
|
|
export PATH="/usr/local/go/bin:$PATH"; \
|
|
go version
|
|
|
|
ENV GOPATH /go
|
|
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
|
|
|
|
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
|
|
|
|
ENV PATH $PATH:$GOPATH/bin
|
|
ENV CGO_ENABLED 0
|
|
ENV MINIO_UPDATE off
|
|
ENV MINIO_ACCESS_KEY_FILE=access_key \
|
|
MINIO_SECRET_KEY_FILE=secret_key
|
|
|
|
WORKDIR /go/src/github.com/minio/
|
|
|
|
COPY healthcheck.sh entrypoint.sh /usr/bin/
|
|
|
|
RUN \
|
|
apk add --no-cache ca-certificates 'curl>7.61.0' && \
|
|
apk add --no-cache --virtual .build-deps git && \
|
|
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
|
|
go get -v -d github.com/minio/minio && \
|
|
cd /go/src/github.com/minio/minio && \
|
|
go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" && \
|
|
rm -rf /go/pkg /go/src /usr/local/go && apk del .build-deps
|
|
|
|
COPY access_key secret_key /go/src/github.com/minio/
|
|
|
|
EXPOSE 9000
|
|
|
|
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
|
|
|
|
VOLUME ["/data"]
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s \
|
|
CMD /usr/bin/healthcheck.sh
|
|
|
|
CMD ["server", "/data"] |