vars
This commit is contained in:
parent
82d5e73b35
commit
0543352bf8
3 changed files with 41 additions and 41 deletions
|
|
@ -22,12 +22,21 @@ set -euo pipefail
|
||||||
: "${IMAGE_REGISTRY:?IMAGE_REGISTRY is required}"
|
: "${IMAGE_REGISTRY:?IMAGE_REGISTRY is required}"
|
||||||
: "${PREFIX:?PREFIX is required}"
|
: "${PREFIX:?PREFIX is required}"
|
||||||
: "${OWNER:?OWNER is required}"
|
: "${OWNER:?OWNER is required}"
|
||||||
: "${SERVICES:?SERVICES is required}"
|
|
||||||
: "${USERNAME:?USERNAME is required}"
|
: "${USERNAME:?USERNAME is required}"
|
||||||
: "${TOKEN:?TOKEN is required}"
|
: "${TOKEN:?TOKEN is required}"
|
||||||
: "${ENV_FILE:?ENV_FILE is required}"
|
: "${ENV_FILE:?ENV_FILE is required}"
|
||||||
|
|
||||||
set -x
|
# Load environment variables from the env file
|
||||||
|
if [[ -f "${ENV_FILE}" ]]; then
|
||||||
|
echo "Loading environment from ${ENV_FILE}"
|
||||||
|
set -a # automatically export all variables
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "${ENV_FILE}"
|
||||||
|
set +a
|
||||||
|
else
|
||||||
|
echo "Error: ENV_FILE ${ENV_FILE} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Optional login
|
# Optional login
|
||||||
if [[ -n "${USERNAME}" && -n "${TOKEN}" ]]; then
|
if [[ -n "${USERNAME}" && -n "${TOKEN}" ]]; then
|
||||||
|
|
@ -49,41 +58,34 @@ echo "================================"
|
||||||
echo "PHASE 1: Building all images"
|
echo "PHASE 1: Building all images"
|
||||||
echo "================================"
|
echo "================================"
|
||||||
|
|
||||||
for svc in ${SERVICES}; do
|
IMAGE="${IMAGE_REGISTRY}/${OWNER}/${PREFIX}-web:${TAG}"
|
||||||
case "${svc}" in
|
|
||||||
db)
|
|
||||||
ctx="./apps/db"
|
|
||||||
dockerfile="Dockerfile"
|
|
||||||
;;
|
|
||||||
backend)
|
|
||||||
ctx="./apps/backend"
|
|
||||||
dockerfile="Dockerfile"
|
|
||||||
;;
|
|
||||||
web)
|
|
||||||
ctx="./apps/infoalloggi"
|
|
||||||
dockerfile="Dockerfile"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown service: ${svc}, skipping..."
|
|
||||||
continue
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
IMAGE="${IMAGE_REGISTRY}/${OWNER}/${PREFIX}-${svc}:${TAG}"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Building ${PREFIX}-${svc} -> ${IMAGE} (context: ${ctx})"
|
echo "Building ${PREFIX}-web -> ${IMAGE} (context: ./apps/infoalloggi)"
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg ENV_FILE="${ENV_FILE}" \
|
--build-arg BASE_URL="${BASE_URL}" \
|
||||||
|
--build-arg NEXT_PUBLIC_BASE_URL="${BASE_URL}" \
|
||||||
|
--build-arg NEXT_PUBLIC_STRIPE_PUBLIC_KEY="${NEXT_PUBLIC_STRIPE_PUBLIC_KEY}" \
|
||||||
-t "${IMAGE}" \
|
-t "${IMAGE}" \
|
||||||
--label "org.opencontainers.image.description=${DESCRIPTION}" \
|
--label "org.opencontainers.image.description=${DESCRIPTION}" \
|
||||||
-f "$ctx/$dockerfile" \
|
-f "./apps/infoalloggi/Dockerfile" \
|
||||||
"$ctx"
|
"./apps/infoalloggi"
|
||||||
|
|
||||||
|
BUILT_IMAGES+=("${IMAGE}")
|
||||||
|
echo "✓ Built ${IMAGE}"
|
||||||
|
|
||||||
|
IMAGE="${IMAGE_REGISTRY}/${OWNER}/${PREFIX}-backend:${TAG}"
|
||||||
|
echo ""
|
||||||
|
echo "Building ${PREFIX}-backend -> ${IMAGE} (context: ./apps/backend)"
|
||||||
|
|
||||||
|
docker build \
|
||||||
|
-t "${IMAGE}" \
|
||||||
|
--label "org.opencontainers.image.description=${DESCRIPTION}" \
|
||||||
|
-f "./apps/backend/Dockerfile" \
|
||||||
|
"./apps/backend"
|
||||||
|
|
||||||
# Store the image name for later pushing
|
|
||||||
BUILT_IMAGES+=("${IMAGE}")
|
BUILT_IMAGES+=("${IMAGE}")
|
||||||
echo "✓ Built ${IMAGE}"
|
echo "✓ Built ${IMAGE}"
|
||||||
done
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "================================"
|
echo "================================"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ set -euo pipefail
|
||||||
export TAG="latest"
|
export TAG="latest"
|
||||||
export IMAGE_REGISTRY="ghcr.io"
|
export IMAGE_REGISTRY="ghcr.io"
|
||||||
export OWNER="marcopedone"
|
export OWNER="marcopedone"
|
||||||
export SERVICES="web backend"
|
|
||||||
export USERNAME="marcopedone"
|
export USERNAME="marcopedone"
|
||||||
export TOKEN="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"
|
export TOKEN="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"
|
||||||
export ENV_FILE=".env.infoalloggi"
|
export ENV_FILE=".env.infoalloggi"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ set -euo pipefail
|
||||||
export TAG="latest"
|
export TAG="latest"
|
||||||
export IMAGE_REGISTRY="ghcr.io"
|
export IMAGE_REGISTRY="ghcr.io"
|
||||||
export OWNER="marcopedone"
|
export OWNER="marcopedone"
|
||||||
export SERVICES="web backend"
|
|
||||||
export USERNAME="marcopedone"
|
export USERNAME="marcopedone"
|
||||||
export TOKEN="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"
|
export TOKEN="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"
|
||||||
export ENV_FILE=".env.marcopedone"
|
export ENV_FILE=".env.marcopedone"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue