From 017872c5ef7ca2a761e2b277de5be842c84610cc Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Sun, 29 Oct 2023 11:43:47 +0100 Subject: [PATCH] chore: improving scripts and add thecodingmachine to edge release --- .github/workflows/continuous_integration.yml | 3 ++- scripts/release.sh | 27 +++++--------------- test/docker-entrypoint.sh | 8 +++--- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index ca351262..d1504151 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -62,4 +62,5 @@ jobs: uses: actions/checkout@v4 - name: Build and push Docker image for main branch run: | - make release GOTENBERG_VERSION=edge \ No newline at end of file + make release GOTENBERG_VERSION=edge + make release GOTENBERG_VERSION=edge DOCKER_REPOSITORY=thecodingmachine \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh index b664e0c2..f884fe31 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -10,23 +10,7 @@ NOTO_COLOR_EMOJI_VERSION="$5" PDFTK_VERSION="$6" DOCKER_REPOSITORY="$7" -if [ $GOTENBERG_VERSION == "edge" ]; then -# docker buildx build \ -# --build-arg GOLANG_VERSION="$GOLANG_VERSION" \ -# --build-arg GOTENBERG_VERSION="$GOTENBERG_VERSION" \ -# --build-arg GOTENBERG_USER_GID="$GOTENBERG_USER_GID" \ -# --build-arg GOTENBERG_USER_UID="$GOTENBERG_USER_UID" \ -# --build-arg NOTO_COLOR_EMOJI_VERSION="$NOTO_COLOR_EMOJI_VERSION" \ -# --build-arg PDFTK_VERSION="$PDFTK_VERSION" \ -# --platform linux/amd64 \ -# --platform linux/arm64 \ -# --platform linux/arm/v7 \ -# --platform linux/386 \ -# -t "$DOCKER_REPOSITORY/gotenberg:edge" \ -# --push \ -# -f build/Dockerfile . - - # FIXME: --platform linux/arm/v7 (armhf) not working. +if [ "$GOTENBERG_VERSION" == "edge" ]; then docker buildx build \ --build-arg GOLANG_VERSION="$GOLANG_VERSION" \ --build-arg GOTENBERG_VERSION="$GOTENBERG_VERSION" \ @@ -36,6 +20,7 @@ if [ $GOTENBERG_VERSION == "edge" ]; then --build-arg PDFTK_VERSION="$PDFTK_VERSION" \ --platform linux/amd64 \ --platform linux/arm64 \ + --platform linux/arm/v7 \ --platform linux/386 \ -t "$DOCKER_REPOSITORY/gotenberg:edge" \ --push \ @@ -55,12 +40,12 @@ if [ $GOTENBERG_VERSION == "edge" ]; then fi GOTENBERG_VERSION="${GOTENBERG_VERSION//v}" -SEMVER=( ${GOTENBERG_VERSION//./ } ) +IFS='.' read -ra SEMVER <<< "$GOTENBERG_VERSION" VERSION_LENGTH=${#SEMVER[@]} -if [ $VERSION_LENGTH -ne 3 ]; then - echo "$VERSION is not semver." - exit 1 +if [ "$VERSION_LENGTH" -ne 3 ]; then + echo "$VERSION is not semver." + exit 1 fi docker buildx build \ diff --git a/test/docker-entrypoint.sh b/test/docker-entrypoint.sh index 413e24e2..3ff928a3 100755 --- a/test/docker-entrypoint.sh +++ b/test/docker-entrypoint.sh @@ -12,11 +12,11 @@ HAS_CONSISTENT_RIGHTS=$? if [[ "$HAS_CONSISTENT_RIGHTS" != "0" ]]; then # If not specified, the DOCKER_USER is the owner of the current working directory (heuristic!). - DOCKER_USER=`ls -dl $(pwd) | cut -d " " -f 3` + DOCKER_USER=$(stat -c '%U' "$(pwd)") else # macOs or Windows. # Note: in most cases, we don't care about the rights (they are not respected). - FILE_OWNER=`ls -dl testing_file_system_rights.foo/foo | cut -d " " -f 3` + FILE_OWNER=$(stat -c '%U' "testing_file_system_rights.foo/foo") if [[ "$FILE_OWNER" == "root" ]]; then # If root, we are likely on a Windows host. # All files will belong to root, but it does not matter as everybody can write/delete @@ -38,11 +38,11 @@ unset HAS_CONSISTENT_RIGHTS # DOCKER_USER is an ID. if [[ "$DOCKER_USER" =~ ^[0-9]+$ ]] ; then # Let's change the gotenberg user's ID in order to match this free ID. - usermod -u $DOCKER_USER -G sudo gotenberg + usermod -u "$DOCKER_USER" -G sudo gotenberg DOCKER_USER=gotenberg fi -DOCKER_USER_ID=`id -ur $DOCKER_USER` +DOCKER_USER_ID=$(id -ur $DOCKER_USER) # Fix access rights to stdout and stderr. set +e