From 0a9404a08e35cc1c81d96e147aa5c18de5619076 Mon Sep 17 00:00:00 2001 From: Pau Rodriguez-Estivill Date: Thu, 20 Aug 2020 21:49:36 +0200 Subject: [PATCH] Add build documentation --- BUILD.md | 43 +++++++++++++++++++++++++++++++++++++++++++ publish.sh | 17 +++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 BUILD.md diff --git a/BUILD.md b/BUILD.md new file mode 100644 index 0000000..e282078 --- /dev/null +++ b/BUILD.md @@ -0,0 +1,43 @@ +# postgres-backup-local build instructions + +To build and push all images to it's own repository. + +## Prepare environment + + * Configure you system to use [Docker Buildx](https://docs.docker.com/buildx/working-with-buildx/). + * Prepare crosscompile environment (see below). + +### Prepare crosscompile environment + +In order to work in Arch Linux the following initialization commands will be required: + +```sh +docker run --rm --privileged multiarch/qemu-user-static --reset -p yes +docker buildx rm multibuilder +docker buildx create --name multibuilder --platform linux/amd64,linux/arm64,linux/arm/v7 --driver docker-container --use +docker buildx inspect --bootstrap +``` + +## Generate the images + +### Generate build configuration + +In order to modify the image name or any other configurable parameter run the `generate.sh` script. + +```sh +IMAGE_NAME="prodrigestivill/postgres-backup-local" ./generate.sh config.hcl +``` + +### Build the images + +In order to only build the images locally run the following command: + +```sh +docker buildx bake --pull -f config.hcl +``` + +In order to publish directly to the repository run this command instead: + +```sh +docker buildx bake --pull --set common.output=type=registry -f config.hcl +``` diff --git a/publish.sh b/publish.sh index d01cb5a..3930e57 100755 --- a/publish.sh +++ b/publish.sh @@ -1,8 +1,21 @@ #!/bin/sh +# +# Usage: ./publish.sh [Version1] [Version2]... set -e cd "$(dirname "$0")" -./generate.sh +TMPFILE=$(mktemp) +trap 'rm -vf "$TMPFILE"' EXIT -docker buildx bake --pull --set common.output=type=registry +if [ -n "$@" ]; then + export TAGS="$@" + echo "Generate configuration for only this tags: $TAGS" +else + echo "Generate configuration for all predefined tags." +fi +./generate.sh "$TMPFILE" +echo "Generated docker bake HCL script at: $TMPFILE" + +echo "Starting building and publish..." +docker buildx bake --pull --set common.output=type=registry -f "$TMPFILE"