From 7ccf587c00df644b92421a7b84e0b0188fce84cc Mon Sep 17 00:00:00 2001 From: Mirco Date: Thu, 7 Dec 2023 21:54:20 +0100 Subject: [PATCH] Improvements docker image building --- infrastructure/backup/image/Dockerfile | 4 ++-- .../backup/image/resources/backup.sh | 2 +- .../backup/image/resources/end-maintenance.sh | 2 +- .../resources/entrypoint-start-and-wait.sh | 2 ++ .../backup/image/resources/entrypoint.sh | 2 ++ infrastructure/backup/image/resources/init.sh | 2 ++ .../backup/image/resources/install.sh | 2 ++ .../backup/image/resources/list-snapshots.sh | 2 +- .../backup/image/resources/restore.sh | 2 +- .../image/resources/start-maintenance.sh | 2 -- infrastructure/backup/test/Dockerfile | 10 -------- infrastructure/nextcloud/image/Dockerfile | 4 ++-- .../nextcloud/image/resources/install.sh | 23 +++++++++++++------ infrastructure/nextcloud/test/Dockerfile | 10 -------- 14 files changed, 32 insertions(+), 37 deletions(-) delete mode 100644 infrastructure/backup/test/Dockerfile delete mode 100644 infrastructure/nextcloud/test/Dockerfile diff --git a/infrastructure/backup/image/Dockerfile b/infrastructure/backup/image/Dockerfile index 87f0f16..b31010f 100644 --- a/infrastructure/backup/image/Dockerfile +++ b/infrastructure/backup/image/Dockerfile @@ -1,5 +1,5 @@ -FROM domaindrivenarchitecture/dda-backup:1.0.9 +FROM domaindrivenarchitecture/dda-backup:latest # Prepare Entrypoint Script ADD resources /tmp -RUN /tmp/install.sh +RUN DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes /tmp/install.sh diff --git a/infrastructure/backup/image/resources/backup.sh b/infrastructure/backup/image/resources/backup.sh index b7fe1be..76c203b 100755 --- a/infrastructure/backup/image/resources/backup.sh +++ b/infrastructure/backup/image/resources/backup.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -o pipefail +set -Eexo pipefail function main() { diff --git a/infrastructure/backup/image/resources/end-maintenance.sh b/infrastructure/backup/image/resources/end-maintenance.sh index 0976fe5..e3c3a96 100644 --- a/infrastructure/backup/image/resources/end-maintenance.sh +++ b/infrastructure/backup/image/resources/end-maintenance.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -x +set -exo pipefail if test -f "/var/backups/config/config.orig"; then diff --git a/infrastructure/backup/image/resources/entrypoint-start-and-wait.sh b/infrastructure/backup/image/resources/entrypoint-start-and-wait.sh index 60075b5..58d847b 100644 --- a/infrastructure/backup/image/resources/entrypoint-start-and-wait.sh +++ b/infrastructure/backup/image/resources/entrypoint-start-and-wait.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -exo pipefail + function main() { file_env POSTGRES_DB file_env POSTGRES_PASSWORD diff --git a/infrastructure/backup/image/resources/entrypoint.sh b/infrastructure/backup/image/resources/entrypoint.sh index 480c971..3bdf754 100755 --- a/infrastructure/backup/image/resources/entrypoint.sh +++ b/infrastructure/backup/image/resources/entrypoint.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -Eexo pipefail + function main() { file_env POSTGRES_DB file_env POSTGRES_PASSWORD diff --git a/infrastructure/backup/image/resources/init.sh b/infrastructure/backup/image/resources/init.sh index 5767e69..fb33f35 100755 --- a/infrastructure/backup/image/resources/init.sh +++ b/infrastructure/backup/image/resources/init.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -Eexo pipefail + function main() { file_env AWS_ACCESS_KEY_ID file_env AWS_SECRET_ACCESS_KEY diff --git a/infrastructure/backup/image/resources/install.sh b/infrastructure/backup/image/resources/install.sh index 1fe81e5..35ab462 100755 --- a/infrastructure/backup/image/resources/install.sh +++ b/infrastructure/backup/image/resources/install.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -exo pipefail + install -m 0700 /tmp/entrypoint.sh / install -m 0700 /tmp/entrypoint-start-and-wait.sh / diff --git a/infrastructure/backup/image/resources/list-snapshots.sh b/infrastructure/backup/image/resources/list-snapshots.sh index b62a34a..10ca9dd 100755 --- a/infrastructure/backup/image/resources/list-snapshots.sh +++ b/infrastructure/backup/image/resources/list-snapshots.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -o pipefail +set -exo pipefail function list-snapshot-files() { if [ -z ${CERTIFICATE_FILE} ]; diff --git a/infrastructure/backup/image/resources/restore.sh b/infrastructure/backup/image/resources/restore.sh index 0098b86..44db019 100755 --- a/infrastructure/backup/image/resources/restore.sh +++ b/infrastructure/backup/image/resources/restore.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -Eeox pipefail +set -Eexo pipefail function main() { local role_snapshot_id="${1:-latest}" diff --git a/infrastructure/backup/image/resources/start-maintenance.sh b/infrastructure/backup/image/resources/start-maintenance.sh index e3bbace..916bbca 100644 --- a/infrastructure/backup/image/resources/start-maintenance.sh +++ b/infrastructure/backup/image/resources/start-maintenance.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -x - if [ ! -f "/var/backups/config/config.orig" ]; then rm -f /var/backups/config/config.orig diff --git a/infrastructure/backup/test/Dockerfile b/infrastructure/backup/test/Dockerfile deleted file mode 100644 index a8aa422..0000000 --- a/infrastructure/backup/test/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM c4k-cloud-backup - -RUN apt update > /dev/null -RUN apt -yqq --no-install-recommends --yes install curl default-jre-headless > /dev/null - -RUN curl -L -o /tmp/serverspec.jar https://github.com/DomainDrivenArchitecture/dda-serverspec-crate/releases/download/2.0.0/dda-serverspec-standalone.jar - -COPY serverspec.edn /tmp/serverspec.edn - -RUN java -jar /tmp/serverspec.jar /tmp/serverspec.edn -v \ No newline at end of file diff --git a/infrastructure/nextcloud/image/Dockerfile b/infrastructure/nextcloud/image/Dockerfile index e65e42b..8279683 100644 --- a/infrastructure/nextcloud/image/Dockerfile +++ b/infrastructure/nextcloud/image/Dockerfile @@ -1,8 +1,8 @@ -FROM nextcloud:25 +FROM nextcloud:27 # Prepare Entrypoint Script ADD resources /tmp -RUN /tmp/install.sh +RUN DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes /tmp/install.sh ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] diff --git a/infrastructure/nextcloud/image/resources/install.sh b/infrastructure/nextcloud/image/resources/install.sh index 2111956..1a37e42 100755 --- a/infrastructure/nextcloud/image/resources/install.sh +++ b/infrastructure/nextcloud/image/resources/install.sh @@ -1,11 +1,20 @@ #!/bin/bash -set -Eeo pipefail +set -exo pipefail -apt update && apt -qqy install postgresql-client > /dev/null +function main() { + { + upgradeSystem + apt-get install -qqy ca-certificates curl gnupg postgresql-client + mkdir /var/data + } > /dev/null -mkdir /var/data + install -m 0700 /tmp/install-debug.sh /usr/local/bin/ + install -m 0544 /tmp/upload-max-limit.ini /usr/local/etc/php/conf.d/ + install -m 0544 /tmp/memory-limit.ini /usr/local/etc/php/conf.d/ + install -m 0755 /tmp/entrypoint.sh / + + cleanupDocker +} -install -m 0700 /tmp/install-debug.sh /usr/local/bin/ -install -m 0544 /tmp/upload-max-limit.ini /usr/local/etc/php/conf.d/ -install -m 0544 /tmp/memory-limit.ini /usr/local/etc/php/conf.d/ -install -m 0755 /tmp/entrypoint.sh / \ No newline at end of file +source /tmp/install_functions.sh +main \ No newline at end of file diff --git a/infrastructure/nextcloud/test/Dockerfile b/infrastructure/nextcloud/test/Dockerfile deleted file mode 100644 index a1d76b9..0000000 --- a/infrastructure/nextcloud/test/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM c4k-cloud - -RUN apt-get update -RUN apt-get -yqq install --no-install-recommends --yes curl default-jre-headless - -RUN curl -L -o /tmp/serverspec.jar https://github.com/DomainDrivenArchitecture/dda-serverspec-crate/releases/download/2.0.0/dda-serverspec-standalone.jar - -COPY serverspec.edn /tmp/serverspec.edn - -RUN java -jar /tmp/serverspec.jar /tmp/serverspec.edn -v