Add more architectures, moved to docker baker build system

This commit is contained in:
Pau Rodriguez-Estivill
2020-02-11 18:45:46 +01:00
parent bac1647953
commit f7301fd81e
7 changed files with 180 additions and 19 deletions
+6 -2
View File
@@ -1,8 +1,12 @@
FROM postgres:alpine
ARG BASETAG=alpine
FROM postgres:$BASETAG
ARG GOCRONVER=v0.0.8
ARG TARGETOS
ARG TARGETARCH
RUN set -x \
&& apk update && apk add ca-certificates curl \
&& curl -L https://github.com/prodrigestivill/go-cron/releases/download/v0.0.8/go-cron-linux-amd64-static.gz | zcat > /usr/local/bin/go-cron \
&& curl -L https://github.com/prodrigestivill/go-cron/releases/download/$GOCRONVER/go-cron-$TARGETOS-$TARGETARCH-static.gz | zcat > /usr/local/bin/go-cron \
&& chmod a+x /usr/local/bin/go-cron \
&& apk del ca-certificates
+6 -2
View File
@@ -1,8 +1,12 @@
FROM postgres
ARG BASETAG=latest
FROM postgres:$BASETAG
ARG GOCRONVER=v0.0.8
ARG TARGETOS
ARG TARGETARCH
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && rm -rf /var/lib/apt/lists/* \
&& curl -L https://github.com/prodrigestivill/go-cron/releases/download/v0.0.8/go-cron-linux-amd64.gz | zcat > /usr/local/bin/go-cron \
&& curl -L https://github.com/prodrigestivill/go-cron/releases/download/$GOCRONVER/go-cron-$TARGETOS-$TARGETARCH.gz | zcat > /usr/local/bin/go-cron \
&& chmod a+x /usr/local/bin/go-cron \
&& apt-get purge -y --auto-remove ca-certificates && apt-get clean
+4
View File
@@ -1,8 +1,12 @@
![Docker Pulls](https://img.shields.io/docker/pulls/prodrigestivill/postgres-backup-local)
# postgres-backup-local
Backup PostgresSQL to the local filesystem with periodic rotating backups, based on [schickling/postgres-backup-s3](https://hub.docker.com/r/schickling/postgres-backup-s3/).
Backup multiple databases from the same host by setting the database names in `POSTGRES_DB` separated by commas or spaces.
Supports the following Docker architectures: `linux/amd64`, `linux/arm64`, `linux/arm/v7`.
## Usage
Docker:
+90
View File
@@ -0,0 +1,90 @@
group "default" {
targets = ["debian-latest", "alpine-latest", "debian-11", "debian-10", "debian-9.6", "debian-9.5", "debian-9.4", "alpine-11", "alpine-10", "alpine-9.6", "alpine-9.5", "alpine-9.4"]
}
target "common" {
platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7"]
args = {"GOCRONVER" = "v0.0.8"}
}
target "debian" {
inherits = ["common"]
dockerfile = "Dockerfile-debian"
}
target "alpine" {
inherits = ["common"]
dockerfile = "Dockerfile-alpine"
}
target "debian-latest" {
inherits = ["debian"]
args = {"BASETAG" = "12"}
tags = ["prodrigestivill/postgres-backup-local:latest", "prodrigestivill/postgres-backup-local:12"]
}
target "alpine-latest" {
inherits = ["alpine"]
args = {"BASETAG" = "12-alpine"}
tags = ["prodrigestivill/postgres-backup-local:alpine", "prodrigestivill/postgres-backup-local:12-alpine"]
}
target "debian-11" {
inherits = ["debian"]
args = {"BASETAG" = "11"}
tags = ["prodrigestivill/postgres-backup-local:11"]
}
target "alpine-11" {
inherits = ["alpine"]
args = {"BASETAG" = "11-alpine"}
tags = ["prodrigestivill/postgres-backup-local:11-alpine"]
}
target "debian-10" {
inherits = ["debian"]
args = {"BASETAG" = "10"}
tags = ["prodrigestivill/postgres-backup-local:10"]
}
target "alpine-10" {
inherits = ["alpine"]
args = {"BASETAG" = "10-alpine"}
tags = ["prodrigestivill/postgres-backup-local:10-alpine"]
}
target "debian-9.6" {
inherits = ["debian"]
args = {"BASETAG" = "9.6"}
tags = ["prodrigestivill/postgres-backup-local:9.6"]
}
target "alpine-9.6" {
inherits = ["alpine"]
args = {"BASETAG" = "9.6-alpine"}
tags = ["prodrigestivill/postgres-backup-local:9.6-alpine"]
}
target "debian-9.5" {
inherits = ["debian"]
args = {"BASETAG" = "9.5"}
tags = ["prodrigestivill/postgres-backup-local:9.5"]
}
target "alpine-9.5" {
inherits = ["alpine"]
args = {"BASETAG" = "9.5-alpine"}
tags = ["prodrigestivill/postgres-backup-local:9.5-alpine"]
}
target "debian-9.4" {
inherits = ["debian"]
args = {"BASETAG" = "9.4"}
tags = ["prodrigestivill/postgres-backup-local:9.4"]
}
target "alpine-9.4" {
inherits = ["alpine"]
args = {"BASETAG" = "9.4-alpine"}
tags = ["prodrigestivill/postgres-backup-local:9.4-alpine"]
}
Executable
+66
View File
@@ -0,0 +1,66 @@
#!/bin/sh
set -e
DOCKER_BAKE_FILE=${1:-"docker-bake.hcl"}
TAGS=${TAGS:-"12 11 10 9.6 9.5 9.4"}
GOCRONVER=${GOCRONVER:-"v0.0.8"}
PLATFORMS=${PLATFORMS:-"linux/amd64 linux/arm64 linux/arm/v7"}
IMAGE_NAME=${IMAGE_NAME:-"prodrigestivill/postgres-backup-local"}
cd "$(dirname "$0")"
MAIN_TAG=${TAGS%%" "*} # First tag
TAGS_EXTRA=${TAGS#*" "} # Rest of tags
P="\"$(echo $PLATFORMS | sed 's/ /", "/g')\""
T="\"debian-latest\", \"alpine-latest\", \"$(echo debian-$TAGS_EXTRA | sed 's/ /", "debian-/g')\", \"$(echo alpine-$TAGS_EXTRA | sed 's/ /", "alpine-/g')\""
cat > "$DOCKER_BAKE_FILE" << EOF
group "default" {
targets = [$T]
}
target "common" {
platforms = [$P]
args = {"GOCRONVER" = "$GOCRONVER"}
}
target "debian" {
inherits = ["common"]
dockerfile = "Dockerfile-debian"
}
target "alpine" {
inherits = ["common"]
dockerfile = "Dockerfile-alpine"
}
target "debian-latest" {
inherits = ["debian"]
args = {"BASETAG" = "$MAIN_TAG"}
tags = ["$IMAGE_NAME:latest", "$IMAGE_NAME:$MAIN_TAG"]
}
target "alpine-latest" {
inherits = ["alpine"]
args = {"BASETAG" = "$MAIN_TAG-alpine"}
tags = ["$IMAGE_NAME:alpine", "$IMAGE_NAME:$MAIN_TAG-alpine"]
}
EOF
for TAG in $TAGS_EXTRA; do cat >> "$DOCKER_BAKE_FILE" << EOF
target "debian-$TAG" {
inherits = ["debian"]
args = {"BASETAG" = "$TAG"}
tags = ["$IMAGE_NAME:$TAG"]
}
target "alpine-$TAG" {
inherits = ["alpine"]
args = {"BASETAG" = "$TAG-alpine"}
tags = ["$IMAGE_NAME:$TAG-alpine"]
}
EOF
done
Executable
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
cd "$(dirname "$0")"
./generate.sh
docker buildx bake --pull --set common.output=type=registry
-15
View File
@@ -1,15 +0,0 @@
#!/bin/sh -e
TAGS="12 11 10 9.6 9.5 9.4"
git push --tags -f
git reset --hard
for TAG in $TAGS; do
sed -i "1 s,\$,:${TAG}," Dockerfile-debian
sed -i "1 s,:alpine\$,:${TAG}-alpine," Dockerfile-alpine
git commit -m "Tag $TAG" Dockerfile-*
git tag -f "$TAG"
# github events needs to push each tag separately
git push --tags -f
git reset HEAD^
git reset --hard
done