Skip to content

Commit

Permalink
chore: bump alpine base image and go to fix CVEs (#12026)
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorwhitney authored Feb 22, 2024
1 parent b970886 commit 2151471
Show file tree
Hide file tree
Showing 64 changed files with 3,100 additions and 1,106 deletions.
1 change: 1 addition & 0 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches:
- 'main'
- 'master'
- 'release-[0-9]+.[0-9]+.x'
workflow_dispatch:

jobs:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ pkg/loki/wal

# nix
result

# snyk/trivy
.dccache
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -812,17 +812,14 @@ dev-k3d-down:

# Trivy is used to scan images for vulnerabilities
.PHONY: trivy
trivy: loki-image build-image
trivy: loki-image
trivy i $(IMAGE_PREFIX)/loki:$(IMAGE_TAG)
trivy i $(IMAGE_PREFIX)/loki-build-image:$(IMAGE_TAG)
trivy fs go.mod

# Synk is also used to scan for vulnerabilities, and detects things that trivy might miss
.PHONY: snyk
snyk: loki-image build-image
snyk container test $(IMAGE_PREFIX)/loki:$(IMAGE_TAG) --file=cmd/loki/Dockerfile
snyk container test $(IMAGE_PREFIX)/loki-build-image:$(IMAGE_TAG) --file=loki-build-image/Dockerfile
snyk code test
snyk:
snyk test

.PHONY: scan-vulnerabilities
scan-vulnerabilities: trivy snyk
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/docker-driver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false clients/cmd/docker-driver/docker-driver

FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates tzdata
COPY --from=build /src/loki/clients/cmd/docker-driver/docker-driver /bin/docker-driver
WORKDIR /bin/
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/promtail/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.10-bullseye as build
FROM golang:1.20.12-bullseye as build

COPY . /src/loki
WORKDIR /src/loki
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/promtail/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false PROMTAIL_JOURNAL_ENABLED=true promtail-debug


FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates tzdata
COPY --from=build /src/loki/clients/cmd/promtail/promtail-debug /usr/bin/promtail-debug
COPY --from=build /usr/bin/dlv /usr/bin/dlv
Expand Down
4 changes: 2 additions & 2 deletions cmd/logcli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.20.10 as build
FROM golang:1.20.12 as build

COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false logcli

FROM alpine:3.18.5
FROM alpine:3.18.6

RUN apk add --no-cache ca-certificates

Expand Down
4 changes: 2 additions & 2 deletions cmd/logql-analyzer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.20.10 as build
FROM golang:1.20.12 as build

COPY . /src/loki
WORKDIR /src/loki
RUN make clean && CGO_ENABLED=0 go build ./cmd/logql-analyzer/

FROM alpine:3.18.5
FROM alpine:3.18.6

RUN apk add --no-cache ca-certificates

Expand Down
4 changes: 2 additions & 2 deletions cmd/loki-canary-boringcrypto/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.20.10 as build
FROM golang:1.20.12 as build

COPY . /src/loki
WORKDIR /src/loki
RUN go env GOARCH > /goarch
RUN make clean && make GOARCH=$(cat /goarch) BUILD_IN_CONTAINER=true GOEXPERIMENT=boringcrypto loki-canary-boringcrypto

FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates
RUN apk add --no-cache libc6-compat
COPY --from=build /src/loki/cmd/loki-canary-boringcrypto/loki-canary-boringcrypto /usr/bin/loki-canary
Expand Down
4 changes: 2 additions & 2 deletions cmd/loki-canary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.20.10 as build
FROM golang:1.20.12 as build

COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false loki-canary

FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates
COPY --from=build /src/loki/cmd/loki-canary/loki-canary /usr/bin/loki-canary
ENTRYPOINT [ "/usr/bin/loki-canary" ]
2 changes: 1 addition & 1 deletion cmd/loki-canary/Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY . /src/loki
WORKDIR /src/loki
RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki-canary

FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates
COPY --from=build /src/loki/cmd/loki-canary/loki-canary /usr/bin/loki-canary
ENTRYPOINT [ "/usr/bin/loki-canary" ]
4 changes: 2 additions & 2 deletions cmd/loki/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.20.10 as build
FROM golang:1.20.12 as build

COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false loki

FROM alpine:3.18.5
FROM alpine:3.18.6

RUN apk add --no-cache ca-certificates libcap

Expand Down
2 changes: 1 addition & 1 deletion cmd/loki/Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY . /src/loki
WORKDIR /src/loki
RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki

FROM alpine:3.18.5
FROM alpine:3.18.6

RUN apk add --no-cache ca-certificates

Expand Down
2 changes: 1 addition & 1 deletion cmd/loki/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WORKDIR /src/loki
RUN make clean && \
GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki-debug

FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates
COPY --from=build /src/loki/cmd/loki/loki-debug /usr/bin/loki-debug
COPY --from=goenv /go/bin/dlv /usr/bin/dlv
Expand Down
4 changes: 2 additions & 2 deletions cmd/migrate/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM golang:1.20.10 as build
FROM golang:1.20.12 as build
COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false migrate

FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates
COPY --from=build /src/loki/cmd/migrate/migrate /usr/bin/migrate
#ENTRYPOINT [ "/usr/bin/migrate" ]
Expand Down
4 changes: 2 additions & 2 deletions cmd/querytee/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.20.10 as build
FROM golang:1.20.12 as build

COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false loki-querytee

FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates
COPY --from=build /src/loki/cmd/querytee/querytee /usr/bin/querytee
ENTRYPOINT [ "/usr/bin/querytee" ]
2 changes: 1 addition & 1 deletion cmd/querytee/Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY . /src/loki
WORKDIR /src/loki
RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki-querytee

FROM alpine:3.18.5
FROM alpine:3.18.6
RUN apk add --update --no-cache ca-certificates
COPY --from=build /src/loki/cmd/querytee/querytee /usr/bin/querytee
ENTRYPOINT [ "/usr/bin/querytee" ]
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ require (
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2561,8 +2561,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
Expand Down
26 changes: 13 additions & 13 deletions loki-build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@
# See ../docs/sources/maintaining/release-loki-build-image.md

# Install helm (https://helm.sh/) and helm-docs (https://github.com/norwoodj/helm-docs) for generating Helm Chart reference.
FROM golang:1.20.10-bullseye as helm
FROM golang:1.20.12-bullseye as helm
ARG HELM_VER="v3.2.3"
RUN curl -L -o /tmp/helm-$HELM_VER.tgz https://get.helm.sh/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
RUN GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/[email protected]

FROM alpine:3.18.5 as lychee
FROM alpine:3.18.6 as lychee
ARG LYCHEE_VER="0.7.0"
RUN apk add --no-cache curl && \
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 && \
tar -xz -C /tmp -f /tmp/lychee-$LYCHEE_VER.tgz && \
mv /tmp/lychee /usr/bin/lychee && \
rm -rf /tmp/linux-amd64 /tmp/lychee-$LYCHEE_VER.tgz

FROM alpine:3.18.5 as golangci
FROM alpine:3.18.6 as golangci
RUN apk add --no-cache curl && \
cd / && \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2

FROM alpine:3.18.5 as buf
FROM alpine:3.18.6 as buf

RUN apk add --no-cache curl && \
curl -sSL "https://github.com/bufbuild/buf/releases/download/v1.4.0/buf-$(uname -s)-$(uname -m)" -o "/usr/bin/buf" && \
chmod +x "/usr/bin/buf"

FROM alpine:3.18.5 as docker
FROM alpine:3.18.6 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.20.10-bullseye as drone
FROM golang:1.20.12-bullseye as drone
RUN curl -L https://github.com/drone/drone-cli/releases/download/v1.4.0/drone_linux_amd64.tar.gz | tar zx && \
install -t /usr/local/bin drone

Expand All @@ -47,32 +47,32 @@ RUN curl -L https://github.com/drone/drone-cli/releases/download/v1.4.0/drone_li
# Error:
# github.com/fatih/[email protected] requires golang.org/x/[email protected]
# (not golang.org/x/[email protected] from golang.org/x/tools/cmd/goyacc@58d531046acdc757f177387bc1725bfa79895d69)
FROM golang:1.20.10-bullseye as faillint
FROM golang:1.20.12-bullseye as faillint
RUN GO111MODULE=on go install github.com/fatih/[email protected]

FROM golang:1.20.10-bullseye as delve
FROM golang:1.20.12-bullseye as delve
RUN GO111MODULE=on go install github.com/go-delve/delve/cmd/dlv@latest

# Install ghr used to push binaries and template the release
# 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.
FROM golang:1.20.10-bullseye as ghr
FROM golang:1.20.12-bullseye as ghr
RUN GO111MODULE=on go install github.com/tcnksm/ghr@9349474

# Install nfpm (https://nfpm.goreleaser.com) for creating .deb and .rpm packages.
FROM golang:1.20.10-bullseye as nfpm
FROM golang:1.20.12-bullseye as nfpm
RUN GO111MODULE=on go install github.com/goreleaser/nfpm/v2/cmd/[email protected]

# Install gotestsum
FROM golang:1.20.10-bullseye as gotestsum
FROM golang:1.20.12-bullseye as gotestsum
RUN GO111MODULE=on go install gotest.tools/[email protected]

# Install tools used to compile jsonnet.
FROM golang:1.20.10-bullseye as jsonnet
FROM golang:1.20.12-bullseye as jsonnet
RUN GO111MODULE=on go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/[email protected]
RUN GO111MODULE=on go install github.com/monitoring-mixins/mixtool/cmd/mixtool@bca3066
RUN GO111MODULE=on go install github.com/google/go-jsonnet/cmd/[email protected]

FROM golang:1.20.10-bullseye
FROM golang:1.20.12-bullseye
RUN apt-get update && \
apt-get install -qy \
musl gnupg ragel \
Expand Down
2 changes: 1 addition & 1 deletion operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.20.10 as builder
FROM golang:1.20.12 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion tools/dev/loki-boltdb-storage-s3/dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang:1.20.4
ENV CGO_ENABLED=0
RUN go install github.com/go-delve/delve/cmd/[email protected]

FROM alpine:3.18.5
FROM alpine:3.18.6

RUN mkdir /loki
WORKDIR /loki
Expand Down
4 changes: 2 additions & 2 deletions tools/lambda-promtail/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.10-alpine AS build-image
FROM golang:1.20.12-alpine AS build-image

COPY tools/lambda-promtail /src/lambda-promtail
WORKDIR /src/lambda-promtail
Expand All @@ -12,7 +12,7 @@ RUN go mod download
RUN go build -o ./main -tags lambda.norpc -ldflags="-s -w" lambda-promtail/*.go


FROM alpine:3.18.5
FROM alpine:3.18.6

WORKDIR /app

Expand Down
Loading

0 comments on commit 2151471

Please sign in to comment.