github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/loki-build-image/Dockerfile (about) 1 # This is the Dockerfile for the Loki build image that is used by the CI 2 # pipelines. 3 # If you make changes to this Dockerfile you also need to update the 4 # tag of the Docker image in `../.drone/drone.jsonnet` and run `make drone`. 5 # See ../docs/sources/maintaining/release-loki-build-image.md 6 7 FROM alpine as helm 8 ARG HELM_VER="v3.2.3" 9 10 RUN apk add --no-cache curl && \ 11 curl -L -o /tmp/helm-$HELM_VER.tgz https://get.helm.sh/helm-${HELM_VER}-linux-amd64.tar.gz && \ 12 tar -xz -C /tmp -f /tmp/helm-$HELM_VER.tgz && \ 13 mv /tmp/linux-amd64/helm /usr/bin/helm && \ 14 rm -rf /tmp/linux-amd64 /tmp/helm-$HELM_VER.tgz 15 16 FROM alpine as lychee 17 ARG LYCHEE_VER="0.7.0" 18 RUN apk add --no-cache curl && \ 19 curl -L -o /tmp/lychee-$LYCHEE_VER.tgz https://github.com/lycheeverse/lychee/releases/download/${LYCHEE_VER}/lychee-${LYCHEE_VER}-x86_64-unknown-linux-gnu.tar.gz && \ 20 tar -xz -C /tmp -f /tmp/lychee-$LYCHEE_VER.tgz && \ 21 mv /tmp/lychee /usr/bin/lychee && \ 22 rm -rf /tmp/linux-amd64 /tmp/lychee-$LYCHEE_VER.tgz 23 24 FROM alpine as golangci 25 RUN apk add --no-cache curl && \ 26 cd / && \ 27 curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.2 28 29 FROM alpine:3.15.4 as buf 30 31 RUN apk add --no-cache curl && \ 32 curl -sSL "https://github.com/bufbuild/buf/releases/download/v1.4.0/buf-$(uname -s)-$(uname -m)" -o "/usr/bin/buf" && \ 33 chmod +x "/usr/bin/buf" 34 35 FROM alpine:3.15.4 as docker 36 RUN apk add --no-cache docker-cli 37 38 # TODO this should be fixed to download and extract the specific release binary from github as we do for golangci and helm above 39 # however we need a commit which hasn't been released yet: https://github.com/drone/drone-cli/commit/1fad337d74ca0ecf420993d9d2d7229a1c99f054 40 # Read the comment below regarding GO111MODULE=on and why it is necessary 41 FROM golang:1.18.4 as drone 42 RUN curl -L https://github.com/drone/drone-cli/releases/download/v1.4.0/drone_linux_amd64.tar.gz | tar zx && \ 43 install -t /usr/local/bin drone 44 45 # Install faillint used to lint go imports in CI. 46 # This collisions with the version of go tools used in the base image, thus we install it in its own image and copy it over. 47 # Error: 48 # github.com/fatih/faillint@v1.5.0 requires golang.org/x/tools@v0.0.0-20200207224406-61798d64f025 49 # (not golang.org/x/tools@v0.0.0-20190918214920-58d531046acd from golang.org/x/tools/cmd/goyacc@58d531046acdc757f177387bc1725bfa79895d69) 50 FROM golang:1.18.4 as faillint 51 RUN GO111MODULE=on go install github.com/fatih/faillint@v1.10.0 52 53 FROM golang:1.18.4 as delve 54 RUN GO111MODULE=on go install github.com/go-delve/delve/cmd/dlv@v1.7.3 55 56 # Install ghr used to push binaries and template the release 57 # This collides with the version of go tools used in the base image, thus we install it in its own image and copy it over. 58 FROM golang:1.18.4 as ghr 59 RUN GO111MODULE=on go install github.com/tcnksm/ghr@9349474 60 61 # Install nfpm (https://nfpm.goreleaser.com) for creating .deb and .rpm packages. 62 FROM golang:1.18.4 as nfpm 63 RUN GO111MODULE=on go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.11.3 64 65 # Install tools used to compile jsonnet. 66 FROM golang:1.18.4 as jsonnet 67 RUN GO111MODULE=on go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@v0.4.0 68 RUN GO111MODULE=on go install github.com/monitoring-mixins/mixtool/cmd/mixtool@bca3066 69 RUN GO111MODULE=on go install github.com/google/go-jsonnet/cmd/jsonnet@v0.18.0 70 71 FROM golang:1.18.4-buster 72 RUN apt-get update && \ 73 apt-get install -qy \ 74 musl gnupg ragel \ 75 file zip unzip jq gettext\ 76 protobuf-compiler libprotobuf-dev \ 77 libsystemd-dev jq && \ 78 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 79 80 COPY --from=docker /usr/bin/docker /usr/bin/docker 81 COPY --from=helm /usr/bin/helm /usr/bin/helm 82 COPY --from=lychee /usr/bin/lychee /usr/bin/lychee 83 COPY --from=golangci /bin/golangci-lint /usr/local/bin 84 COPY --from=buf /usr/bin/buf /usr/bin/buf 85 COPY --from=drone /usr/local/bin/drone /usr/bin/drone 86 COPY --from=faillint /go/bin/faillint /usr/bin/faillint 87 COPY --from=delve /go/bin/dlv /usr/bin/dlv 88 COPY --from=ghr /go/bin/ghr /usr/bin/ghr 89 COPY --from=nfpm /go/bin/nfpm /usr/bin/nfpm 90 COPY --from=jsonnet /go/bin/jb /usr/bin/jb 91 COPY --from=jsonnet /go/bin/mixtool /usr/bin/mixtool 92 COPY --from=jsonnet /go/bin/jsonnet /usr/bin/jsonnet 93 94 # Install some necessary dependencies. 95 # Forcing GO111MODULE=on is required to specify dependencies at specific versions using the go mod notation. 96 # 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 97 # file for it to detect and switch to Go Modules automatically. 98 # It's possible this can be revisited in newer versions of Go if the behavior around GOPATH vs GO111MODULES changes 99 RUN GO111MODULE=on go install github.com/golang/protobuf/protoc-gen-go@v1.3.1 100 RUN GO111MODULE=on go install github.com/gogo/protobuf/protoc-gen-gogoslick@v1.3.0 101 # Due to the lack of a proper release tag, we use the commit hash of 102 # https://github.com/golang/tools/releases v0.1.7 103 RUN GO111MODULE=on go install golang.org/x/tools/cmd/goyacc@58d531046acdc757f177387bc1725bfa79895d69 104 RUN GO111MODULE=on go install github.com/mitchellh/gox@9f71238 && rm -rf /go/pkg /go/src 105 ENV GOCACHE=/go/cache 106 107 COPY build.sh / 108 RUN chmod +x /build.sh 109 ENTRYPOINT ["/build.sh"]