Support building images via podman (#4978)

This commit is contained in:
PhracturedBlue 2023-11-09 00:50:21 -08:00 committed by GitHub
parent 73a1862182
commit 2474281f1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -1126,6 +1126,18 @@ For example, the following command builds the image on top of [scratch](https://
ROOT_IMAGE=scratch make package-victoria-metrics ROOT_IMAGE=scratch make package-victoria-metrics
``` ```
#### Building VictoriaMetrics with Podman
VictoriaMetrics can be built with Podman in either rootful or rootless mode.
When building via rootlful Podman, simply add `DOCKER=podman` to the relevant `make` commandline. To build
via rootless Podman, add `DOCKER=podman DOCKER_RUN="podman run --userns=keep-id"` to the `make`
commandline.
For example: `make victoria-metrics-pure DOCKER=podman DOCKER_RUN="podman run --userns=keep-id"`
Note that `production` builds are not supported via Podman becuase Podman does not support `buildx`.
## Start with docker-compose ## Start with docker-compose
[Docker-compose](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/deployment/docker/docker-compose.yml) [Docker-compose](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/deployment/docker/docker-compose.yml)

View File

@ -8,9 +8,11 @@ CERTS_IMAGE := alpine:3.18.4
GO_BUILDER_IMAGE := golang:1.21.3-alpine GO_BUILDER_IMAGE := golang:1.21.3-alpine
BUILDER_IMAGE := local/builder:2.0.0-$(shell echo $(GO_BUILDER_IMAGE) | tr :/ __)-1 BUILDER_IMAGE := local/builder:2.0.0-$(shell echo $(GO_BUILDER_IMAGE) | tr :/ __)-1
BASE_IMAGE := local/base:1.1.4-$(shell echo $(ROOT_IMAGE) | tr :/ __)-$(shell echo $(CERTS_IMAGE) | tr :/ __) BASE_IMAGE := local/base:1.1.4-$(shell echo $(ROOT_IMAGE) | tr :/ __)-$(shell echo $(CERTS_IMAGE) | tr :/ __)
DOCKER_BUILD ?= docker build DOCKER ?= docker
DOCKER_COMPOSE ?= docker compose DOCKER_RUN ?= $(DOCKER) run
DOCKER_IMAGE_LS ?= docker image ls --format '{{.Repository}}:{{.Tag}}' DOCKER_BUILD ?= $(DOCKER) build
DOCKER_COMPOSE ?= $(DOCKER) compose
DOCKER_IMAGE_LS ?= $(DOCKER) image ls --format '{{.Repository}}:{{.Tag}}'
package-base: package-base:
($(DOCKER_IMAGE_LS) | grep -q '$(BASE_IMAGE)$$') \ ($(DOCKER_IMAGE_LS) | grep -q '$(BASE_IMAGE)$$') \
@ -29,7 +31,7 @@ package-builder:
app-via-docker: package-builder app-via-docker: package-builder
mkdir -p gocache-for-docker mkdir -p gocache-for-docker
docker run --rm \ $(DOCKER_RUN) --rm \
--user $(shell id -u):$(shell id -g) \ --user $(shell id -u):$(shell id -g) \
--mount type=bind,src="$(shell pwd)",dst=/VictoriaMetrics \ --mount type=bind,src="$(shell pwd)",dst=/VictoriaMetrics \
-w /VictoriaMetrics \ -w /VictoriaMetrics \
@ -44,7 +46,7 @@ app-via-docker: package-builder
app-via-docker-windows: package-builder app-via-docker-windows: package-builder
mkdir -p gocache-for-docker mkdir -p gocache-for-docker
docker run --rm \ $(DOCKER_RUN) --rm \
--user $(shell id -u):$(shell id -g) \ --user $(shell id -u):$(shell id -g) \
--mount type=bind,src="$(shell pwd)",dst=/VictoriaMetrics \ --mount type=bind,src="$(shell pwd)",dst=/VictoriaMetrics \
-w /VictoriaMetrics \ -w /VictoriaMetrics \
@ -72,7 +74,7 @@ publish-via-docker: \
app-via-docker-linux-arm64 \ app-via-docker-linux-arm64 \
app-via-docker-linux-ppc64le \ app-via-docker-linux-ppc64le \
app-via-docker-linux-386 app-via-docker-linux-386
docker buildx build \ $(DOCKER) buildx build \
--platform=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/386 \ --platform=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/386 \
--build-arg certs_image=$(CERTS_IMAGE) \ --build-arg certs_image=$(CERTS_IMAGE) \
--build-arg root_image=$(ROOT_IMAGE) \ --build-arg root_image=$(ROOT_IMAGE) \
@ -86,7 +88,7 @@ publish-via-docker: \
bin bin
run-via-docker: package-via-docker run-via-docker: package-via-docker
docker run -it --rm \ $(DOCKER_RUN) -it --rm \
--user $(shell id -u):$(shell id -g) \ --user $(shell id -u):$(shell id -g) \
--net host \ --net host \
$(DOCKER_OPTS) \ $(DOCKER_OPTS) \