Dockerfile: Allow building docker images locally for different editions (#63893)

* Allow to build different editions from dockerfile

* Fix missing argument on dockerfile
This commit is contained in:
Guilherme Caulada
2023-02-28 21:18:00 +01:00
committed by GitHub
parent bc2f68dc56
commit 69aba3eed3
2 changed files with 31 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ COPY .yarn .yarn
COPY packages packages
COPY plugins-bundled plugins-bundled
RUN yarn install
RUN yarn install --immutable
COPY tsconfig.json .eslintrc .editorconfig .browserslistrc .prettierrc.js babel.config.json .linguirc ./
COPY public public
@@ -30,6 +30,10 @@ RUN yarn build
FROM ${GO_IMAGE} as go-builder
ARG GO_BUILD_TAGS="oss"
ARG WIRE_TAGS="oss"
ARG BINGO="true"
# Install build dependencies
RUN if grep -i -q alpine /etc/issue; then \
apk add --no-cache gcc g++ make; \
@@ -40,9 +44,11 @@ WORKDIR /tmp/grafana
COPY go.* ./
COPY .bingo .bingo
RUN go mod download && \
go install github.com/bwplotka/bingo@latest && \
bingo get
RUN go mod download
RUN if [[ "$BINGO" = "true" ]]; then \
go install github.com/bwplotka/bingo@latest && \
bingo get -v; \
fi
COPY embed.go Makefile build.go package.json ./
COPY cue.mod cue.mod
@@ -55,7 +61,7 @@ COPY scripts scripts
COPY conf conf
COPY .github .github
RUN make build-go
RUN make build-go GO_BUILD_TAGS=${GO_BUILD_TAGS} WIRE_TAGS=${WIRE_TAGS}
FROM ${BASE_IMAGE} as tgz-builder

View File

@@ -165,19 +165,35 @@ shellcheck: $(SH_FILES) ## Run checks for shell scripts.
##@ Docker
TMP_DIR!=mktemp -d
TAG_SUFFIX=$(if $(WIRE_TAGS)!=oss,-$(WIRE_TAGS))
PLATFORM=linux/amd64
build-docker-full: ## Build Docker image for development.
@echo "build docker container"
cp -Lrf . $(TMP_DIR)
DOCKER_BUILDKIT=1 \
docker build \
--tag grafana/grafana:dev .
docker build $(TMP_DIR) \
--platform $(PLATFORM) \
--build-arg BINGO=false \
--build-arg GO_BUILD_TAGS=$(GO_BUILD_TAGS) \
--build-arg WIRE_TAGS=$(WIRE_TAGS) \
--tag grafana/grafana$(TAG_SUFFIX):dev \
$(DOCKER_BUILD_ARGS)
build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development.
@echo "build docker container"
cp -Lrf . $(TMP_DIR)
DOCKER_BUILDKIT=1 \
docker build \
docker build $(TMP_DIR) \
--platform $(PLATFORM) \
--build-arg BINGO=false \
--build-arg GO_BUILD_TAGS=$(GO_BUILD_TAGS) \
--build-arg WIRE_TAGS=$(WIRE_TAGS) \
--build-arg BASE_IMAGE=ubuntu:20.04 \
--build-arg GO_IMAGE=golang:1.20.1 \
--tag grafana/grafana:dev-ubuntu .
--tag grafana/grafana$(TAG_SUFFIX):dev-ubuntu \
$(DOCKER_BUILD_ARGS)
##@ Services