From 09e033527fd936916356e73ac3a40d36022d2267 Mon Sep 17 00:00:00 2001 From: Luca Pireddu Date: Mon, 11 Jan 2021 13:13:32 +0100 Subject: [PATCH 1/2] Add make rule to build amd64 and armv7 docker images with docker buildx --- Makefile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c645b53f..bf52cadd 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,25 @@ -FULLTAG=alpinebased:grafana-backup + +DOCKER_REPO ?= ysde +DOCKER_NAME := grafana-backup +DOCKER_TAG ?= latest +PLATFORMS ?= linux/amd64,linux/arm/v7 + +FULLTAG = $(DOCKER_REPO)/$(DOCKER_NAME):$(DOCKER_TAG) + DOCKERFILE=Dockerfile + all: build build: docker build -t $(FULLTAG) -f $(DOCKERFILE) . + push: build docker push $(FULLTAG) + + +buildx_and_push: + docker buildx build \ + --output type=image,name=$(DOCKER_REPO)/$(DOCKER_NAME),push=true \ + --platform linux/amd64,linux/arm/v7 \ + --tag $(FULLTAG) \ + --file $(DOCKERFILE) . From a816bc79809f5f91ebe7ba2f90c80edd7dc47646 Mon Sep 17 00:00:00 2001 From: Luca Pireddu Date: Mon, 11 Jan 2021 14:48:32 +0100 Subject: [PATCH 2/2] Make the image executable by any user. This is important when mounting user volumes onto the container, so that the generated output will be owned by the appropriate user id.. --- Dockerfile | 3 +++ README.md | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b42f0ed0..0b699f61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,9 @@ RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk WORKDIR /opt/grafana-backup-tool ADD . /opt/grafana-backup-tool +RUN chmod -R a+r /opt/grafana-backup-tool \ + && find /opt/grafana-backup-tool -type d -print0 | xargs -0 chmod a+rx + RUN pip3 --no-cache-dir install . RUN chown -R 1337:1337 /opt/grafana-backup-tool diff --git a/README.md b/README.md index bc68ac8e..5576f1a2 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ sudo chown 1337:1337 /tmp/backup ``` ``` -docker run --rm --name grafana-backup-tool \ +docker run --user $(id -u):$(id -g) --rm --name grafana-backup-tool \ -e GRAFANA_TOKEN={YOUR_GRAFANA_TOKEN} \ -e GRAFANA_URL={YOUR_GRAFANA_URL} \ -e GRAFANA_ADMIN_ACCOUNT={YOUR_GRAFANA_ADMIN_ACCOUNT} \ @@ -131,7 +131,7 @@ docker run --rm --name grafana-backup-tool \ ***Example:*** ``` -docker run --rm --name grafana-backup-tool \ +docker run --user $(id -u):$(id -g) --rm --name grafana-backup-tool \ -e GRAFANA_TOKEN="eyJrIjoiNGZqTDEyeXNaY0RsMXNhbkNTSnlKN2M3bE1VeHdqVTEiLCJuIjoiZ3JhZmFuYS1iYWNrdXAiLCJpZCI6MX0=" \ -e GRAFANA_URL=http://192.168.0.79:3000 \ -e GRAFANA_ADMIN_ACCOUNT=admin \ @@ -150,7 +150,7 @@ docker run --rm --name grafana-backup-tool \ ### Restore ``` -docker run --rm --name grafana-backup-tool \ +docker run --user $(id -u):$(id -g) --rm --name grafana-backup-tool \ -e GRAFANA_TOKEN={YOUR_GRAFANA_TOKEN} \ -e GRAFANA_URL={YOUR_GRAFANA_URL} \ -e GRAFANA_ADMIN_ACCOUNT={YOUR_GRAFANA_ADMIN_ACCOUNT} \ @@ -165,7 +165,7 @@ docker run --rm --name grafana-backup-tool \ ***Example:*** ``` -docker run --rm --name grafana-backup-tool \ +docker run --user $(id -u):$(id -g) --rm --name grafana-backup-tool \ -e GRAFANA_TOKEN="eyJrIjoiNGZqTDEyeXNaY0RsMXNhbkNTSnlKN2M3bE1VeHdqVTEiLCJuIjoiZ3JhZmFuYS1iYWNrdXAiLCJpZCI6MX0=" \ -e GRAFANA_URL=http://192.168.0.79:3000 \ -e GRAFANA_ADMIN_ACCOUNT=admin \