forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (50 loc) · 2.49 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
FROM alpine as helm
ARG HELM_VER="v2.13.1"
RUN apk add --no-cache curl && \
curl -L -o /tmp/helm-$HELM_VER.tgz http://storage.googleapis.com/kubernetes-helm/helm-${HELM_VER}-linux-amd64.tar.gz && \
tar -xz -C /tmp -f /tmp/helm-$HELM_VER.tgz && \
mv /tmp/linux-amd64/helm /usr/bin/helm && \
rm -rf /tmp/linux-amd64 /tmp/helm-$HELM_VER.tgz
FROM alpine as golangci
RUN apk add --no-cache curl && \
cd / && \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.21.0
FROM alpine:edge as docker
RUN apk add --no-cache docker-cli
# TODO this should be fixed to download and extract the specific release binary from github as we do for golangci and helm above
# however we need a commit which hasn't been released yet: https://github.com/drone/drone-cli/commit/1fad337d74ca0ecf420993d9d2d7229a1c99f054
# Read the comment below regarding GO111MODULE=on and why it is necessary
FROM golang:1.13.4 as drone
RUN GO111MODULE=on go get github.com/drone/drone-cli/drone@1fad337d74ca0ecf420993d9d2d7229a1c99f054
FROM golang:1.13.4-stretch
RUN apt-get update && \
apt-get install -qy \
musl \
file zip unzip jq gettext\
protobuf-compiler libprotobuf-dev \
libsystemd-dev && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=docker /usr/bin/docker /usr/bin/docker
COPY --from=helm /usr/bin/helm /usr/bin/helm
COPY --from=golangci /bin/golangci-lint /usr/local/bin
COPY --from=drone /go/bin/drone /usr/bin/drone
# Install some necessary dependencies.
# Forcing GO111MODULE=on is required to specify dependencies at specific versions using the go mod notation.
# If we don't force this, Go is going to default to GOPATH mode as we do not have an active project or go.mod
# file for it to detect and switch to Go Modules automatically.
# It's possible this can be revisited in newer versions of Go if the behavior around GOPATH vs GO111MODULES changes
RUN GO111MODULE=on go get \
github.com/golang/protobuf/[email protected] \
github.com/gogo/protobuf/[email protected] \
github.com/gogo/protobuf/[email protected] \
github.com/go-delve/delve/cmd/dlv \
# Due to the lack of a proper release tag, we use the commit hash of
# https://github.com/golang/tools/releases v0.1.7
golang.org/x/tools/cmd/goyacc@58d531046acdc757f177387bc1725bfa79895d69 \
github.com/mitchellh/gox \
github.com/tcnksm/ghr && \
rm -rf /go/pkg /go/src
ENV GOCACHE=/go/cache
COPY build.sh /
RUN chmod +x /build.sh
ENTRYPOINT ["/build.sh"]