From ec5e9ef7da2af05c0721a8786aaf38b51bacec75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ma=C5=A1ek?= Date: Sun, 12 Jan 2025 15:55:30 +0100 Subject: [PATCH] sq --- Dockerfile | 6 ++++++ test_docker.sh | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 60a4b38..d202955 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,12 @@ FROM debian:bullseye-slim +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates curl \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + ARG beacon_binary +RUN if [ -z "$beacon_binary" ]; then echo "ERROR: beacon_binary build argument is required" >&2; exit 1; fi ADD ${beacon_binary} /app/beacon WORKDIR /app diff --git a/test_docker.sh b/test_docker.sh index 56cff3b..4834561 100755 --- a/test_docker.sh +++ b/test_docker.sh @@ -8,16 +8,25 @@ set -o pipefail # Fail if any part of a pipeline fails echo "Starting Beacon test." echo "---------------------" -DOCKER_BUILDKIT=1 docker compose build beacon -echo "Build successful." -echo "-----------------" +# BEACON_BINARY not set +if [ -z "$BEACON_BINARY" ]; then + echo "Building Beacon binary..." + echo "---------------------" + go build . + BEACON_BINARY=./beacon +fi + +echo "Building Docker image..." +echo "---------------------" +DOCKER_BUILDKIT=1 docker build --build-arg beacon_binary=${BEACON_BINARY} -t beacon-test . # try to read env file, but ignore it if it does not exist # in CI the env will be set without this file -source ~/beacon.github.env || true +source ~/beacon.github.env || echo "Ignore missing file in CI" -docker compose run --rm \ - -T \ +echo "Running test..." +echo "---------------------" +docker run --rm \ --entrypoint bash \ -e BEACON_EMAIL_SMTP_SERVER=${BEACON_EMAIL_SMTP_SERVER} \ -e BEACON_EMAIL_SMTP_PORT=${BEACON_EMAIL_SMTP_PORT} \ @@ -26,7 +35,7 @@ docker compose run --rm \ -e BEACON_EMAIL_SEND_TO=${BEACON_EMAIL_SEND_TO} \ -e BEACON_EMAIL_SENDER=${BEACON_EMAIL_SENDER} \ -e BEACON_EMAIL_PREFIX='[staging]' \ - beacon -c ' + beacon-test -c ' set -e /app/beacon start & echo "executing POST"