Skip to content

Commit

Permalink
improve go dependency cacheability, always build go in alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCech committed Nov 15, 2022
1 parent 1c6432c commit 7aed967
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Expand Up @@ -38,22 +38,27 @@ RUN apk add --no-cache gcc g++ make

WORKDIR /tmp/grafana

COPY go.mod go.sum embed.go Makefile build.go package.json ./
COPY go.* ./
COPY .bingo .bingo

RUN go mod download && \
go install github.com/bwplotka/bingo@latest && \
bingo get

COPY embed.go Makefile build.go package.json ./
COPY packages/grafana-schema packages/grafana-schema
COPY public/app/plugins public/app/plugins
COPY public/api-spec.json public/api-spec.json
COPY pkg pkg
COPY scripts scripts
COPY cue.mod cue.mod
COPY .bingo .bingo

RUN go mod verify && \
make build-go
RUN make build-go

# Final stage
FROM ${BASE_IMAGE}

LABEL maintainer="Grafana team <hello@grafana.com>"
LABEL maintainer="Grafana Labs <hello@grafana.com>"

ARG GF_UID="472"
ARG GF_GID="0"
Expand Down
19 changes: 13 additions & 6 deletions Dockerfile.ubuntu
Expand Up @@ -32,26 +32,33 @@ COPY emails emails
ENV NODE_ENV production
RUN yarn build

FROM golang:1.19.3 as go-builder
FROM golang:1.19.3-alpine3.15 as go-builder

RUN apk add --no-cache gcc g++ make

WORKDIR /tmp/grafana

COPY go.mod go.sum embed.go Makefile build.go package.json ./
COPY go.* ./
COPY .bingo .bingo

RUN go mod download && \
go install github.com/bwplotka/bingo@latest && \
bingo get

COPY embed.go Makefile build.go package.json ./
COPY packages/grafana-schema packages/grafana-schema
COPY public/app/plugins public/app/plugins
COPY public/api-spec.json public/api-spec.json
COPY pkg pkg
COPY scripts scripts
COPY cue.mod cue.mod
COPY .bingo .bingo

RUN go mod verify && \
make build-go
RUN make build-go

# Final stage
FROM ${BASE_IMAGE}

LABEL maintainer="Grafana team <hello@grafana.com>"
LABEL maintainer="Grafana Labs <hello@grafana.com>"

ARG GF_UID="472"
ARG GF_GID="0"
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/Dockerfile
Expand Up @@ -28,7 +28,7 @@ RUN tar xzf /tmp/grafana.tar.gz --strip-components=1 -C /tmp/grafana
# Final stage
FROM ${BASE_IMAGE}

LABEL maintainer="Grafana team <hello@grafana.com>"
LABEL maintainer="Grafana Labs <hello@grafana.com>"

ARG GF_UID="472"
ARG GF_GID="0"
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/ubuntu.Dockerfile
Expand Up @@ -25,7 +25,7 @@ RUN tar xzf /tmp/grafana.tar.gz --strip-components=1 -C /tmp/grafana
# Final stage
FROM ${BASE_IMAGE}

LABEL maintainer="Grafana team <hello@grafana.com>"
LABEL maintainer="Grafana Labs <hello@grafana.com>"

ARG GF_UID="472"
ARG GF_GID="0"
Expand Down

0 comments on commit 7aed967

Please sign in to comment.