diff --git a/README.md b/README.md index 842648113..83609b337 100644 --- a/README.md +++ b/README.md @@ -559,6 +559,13 @@ Run `make package-victoria-metrics`. It builds `victoriametrics/victoria-metrics `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package-victoria-metrics`. +By default the image is built on top of `scratch` image. It is possible to build the package on top of any other base image +by setting it via `` environment variable. For example, the following command builds the image on top of `alpine:3.11` image: + +```bash +ROOT_IMAGE=alpine:3.11 make package-victoria-metrics +``` + ### Start with docker-compose [Docker-compose](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/deployment/docker/docker-compose.yml) diff --git a/app/vmagent/README.md b/app/vmagent/README.md index d584b5ff0..3fa50e711 100644 --- a/app/vmagent/README.md +++ b/app/vmagent/README.md @@ -224,3 +224,10 @@ It is recommended using [binary releases](https://github.com/VictoriaMetrics/Vic Run `make package-vmagent`. It builds `victoriametrics/vmagent:` docker image locally. `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package-vmagent`. + +By default the image is built on top of `scratch` image. It is possible to build the package on top of any other base image +by setting it via `` environment variable. For example, the following command builds the image on top of `alpine:3.11` image: + +```bash +ROOT_IMAGE=alpine:3.11 make package-vmagent +``` diff --git a/app/vmbackup/README.md b/app/vmbackup/README.md index 13e07847e..227625205 100644 --- a/app/vmbackup/README.md +++ b/app/vmbackup/README.md @@ -179,3 +179,10 @@ It is recommended using [binary releases](https://github.com/VictoriaMetrics/Vic Run `make package-vmbackup`. It builds `victoriametrics/vmbackup:` docker image locally. `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package-vmbackup`. + +By default the image is built on top of `scratch` image. It is possible to build the package on top of any other base image +by setting it via `` environment variable. For example, the following command builds the image on top of `alpine:3.11` image: + +```bash +ROOT_IMAGE=alpine:3.11 make package-vmbackup +``` diff --git a/app/vmrestore/README.md b/app/vmrestore/README.md index fe071a8d1..f81e42d70 100644 --- a/app/vmrestore/README.md +++ b/app/vmrestore/README.md @@ -84,3 +84,10 @@ It is recommended using [binary releases](https://github.com/VictoriaMetrics/Vic Run `make package-vmrestore`. It builds `victoriametrics/vmrestore:` docker image locally. `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package-vmrestore`. + +By default the image is built on top of `scratch` image. It is possible to build the package on top of any other base image +by setting it via `` environment variable. For example, the following command builds the image on top of `alpine:3.11` image: + +```bash +ROOT_IMAGE=alpine:3.11 make package-vmrestore +``` diff --git a/deployment/docker/Makefile b/deployment/docker/Makefile index ea988b6af..380b7ce39 100644 --- a/deployment/docker/Makefile +++ b/deployment/docker/Makefile @@ -1,16 +1,25 @@ # All these commands must run from repository root. -DOCKER_NAMESPACE := docker.io/victoriametrics -BUILDER_IMAGE := local/builder:go1.14.2 -BASE_IMAGE := local/base:1.1.0 +DOCKER_NAMESPACE := victoriametrics + +ROOT_IMAGE ?= scratch +CERTS_IMAGE := alpine:3.11 +GO_BUILDER_IMAGE := golang:1.14.2 +BUILDER_IMAGE := local/builder:2.0.0-$(shell echo $(GO_BUILDER_IMAGE) | tr : _) +BASE_IMAGE := local/base:1.1.1-$(shell echo $(ROOT_IMAGE) | tr : _)-$(shell echo $(CERTS_IMAGE) | tr : _) package-base: (docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q '$(BASE_IMAGE)$$') \ - || docker build -t $(BASE_IMAGE) deployment/docker/base + || docker build -t $(BASE_IMAGE) \ + --build-arg root_image=$(ROOT_IMAGE) \ + --build-arg certs_image=$(CERTS_IMAGE) \ + deployment/docker/base package-builder: (docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q '$(BUILDER_IMAGE)$$') \ - || docker build -t $(BUILDER_IMAGE) deployment/docker/builder + || docker build -t $(BUILDER_IMAGE) \ + --build-arg go_builder_image=$(GO_BUILDER_IMAGE) \ + deployment/docker/builder app-via-docker: package-base package-builder mkdir -p gocache-for-docker diff --git a/deployment/docker/base/Dockerfile b/deployment/docker/base/Dockerfile index d002cf432..376f8f16e 100644 --- a/deployment/docker/base/Dockerfile +++ b/deployment/docker/base/Dockerfile @@ -1,8 +1,10 @@ # See https://medium.com/on-docker/use-multi-stage-builds-to-inject-ca-certs-ad1e8f01de1b -FROM alpine:3.10 as base +ARG certs_image +ARG root_image +FROM $certs_image as certs RUN apk --update --no-cache add ca-certificates -FROM scratch +FROM $root_image -COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/deployment/docker/builder/Dockerfile b/deployment/docker/builder/Dockerfile index c0a518797..d156d4248 100644 --- a/deployment/docker/builder/Dockerfile +++ b/deployment/docker/builder/Dockerfile @@ -1,2 +1,3 @@ -FROM golang:1.14.2 +ARG go_builder_image +FROM $go_builder_image STOPSIGNAL SIGINT diff --git a/docs/Cluster-VictoriaMetrics.md b/docs/Cluster-VictoriaMetrics.md index b130b8d43..3bd03437a 100644 --- a/docs/Cluster-VictoriaMetrics.md +++ b/docs/Cluster-VictoriaMetrics.md @@ -1,3 +1,5 @@ +Victoria Metrics + # Cluster version VictoriaMetrics is fast, cost-effective and scalable time series database. It can be used as a long-term remote storage for Prometheus. @@ -89,7 +91,12 @@ Run `make package`. It will build the following docker images locally: `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package`. +By default images are built on top of `scratch` image. It is possible to build on top of any other base image +by setting it via `` environment variable. For example, the following command builds images on top of `alpine:3.11` image: +```bash +ROOT_IMAGE=alpine:3.11 make package +``` ## Operation diff --git a/docs/Single-server-VictoriaMetrics.md b/docs/Single-server-VictoriaMetrics.md index 842648113..83609b337 100644 --- a/docs/Single-server-VictoriaMetrics.md +++ b/docs/Single-server-VictoriaMetrics.md @@ -559,6 +559,13 @@ Run `make package-victoria-metrics`. It builds `victoriametrics/victoria-metrics `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package-victoria-metrics`. +By default the image is built on top of `scratch` image. It is possible to build the package on top of any other base image +by setting it via `` environment variable. For example, the following command builds the image on top of `alpine:3.11` image: + +```bash +ROOT_IMAGE=alpine:3.11 make package-victoria-metrics +``` + ### Start with docker-compose [Docker-compose](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/deployment/docker/docker-compose.yml) diff --git a/docs/vmagent.md b/docs/vmagent.md index d584b5ff0..3fa50e711 100644 --- a/docs/vmagent.md +++ b/docs/vmagent.md @@ -224,3 +224,10 @@ It is recommended using [binary releases](https://github.com/VictoriaMetrics/Vic Run `make package-vmagent`. It builds `victoriametrics/vmagent:` docker image locally. `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package-vmagent`. + +By default the image is built on top of `scratch` image. It is possible to build the package on top of any other base image +by setting it via `` environment variable. For example, the following command builds the image on top of `alpine:3.11` image: + +```bash +ROOT_IMAGE=alpine:3.11 make package-vmagent +``` diff --git a/docs/vmbackup.md b/docs/vmbackup.md index 13e07847e..227625205 100644 --- a/docs/vmbackup.md +++ b/docs/vmbackup.md @@ -179,3 +179,10 @@ It is recommended using [binary releases](https://github.com/VictoriaMetrics/Vic Run `make package-vmbackup`. It builds `victoriametrics/vmbackup:` docker image locally. `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package-vmbackup`. + +By default the image is built on top of `scratch` image. It is possible to build the package on top of any other base image +by setting it via `` environment variable. For example, the following command builds the image on top of `alpine:3.11` image: + +```bash +ROOT_IMAGE=alpine:3.11 make package-vmbackup +``` diff --git a/docs/vmrestore.md b/docs/vmrestore.md index fe071a8d1..f81e42d70 100644 --- a/docs/vmrestore.md +++ b/docs/vmrestore.md @@ -84,3 +84,10 @@ It is recommended using [binary releases](https://github.com/VictoriaMetrics/Vic Run `make package-vmrestore`. It builds `victoriametrics/vmrestore:` docker image locally. `` is auto-generated image tag, which depends on source code in the repository. The `` may be manually set via `PKG_TAG=foobar make package-vmrestore`. + +By default the image is built on top of `scratch` image. It is possible to build the package on top of any other base image +by setting it via `` environment variable. For example, the following command builds the image on top of `alpine:3.11` image: + +```bash +ROOT_IMAGE=alpine:3.11 make package-vmrestore +```