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}"
|
||||
: "${PREFIX:?PREFIX is required}"
|
||||
: "${OWNER:?OWNER is required}"
|
||||
: "${SERVICES:?SERVICES is required}"
|
||||
: "${USERNAME:?USERNAME is required}"
|
||||
: "${TOKEN:?TOKEN 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
|
||||
if [[ -n "${USERNAME}" && -n "${TOKEN}" ]]; then
|
||||
|
|
@ -49,41 +58,34 @@ echo "================================"
|
|||
echo "PHASE 1: Building all images"
|
||||
echo "================================"
|
||||
|
||||
for svc in ${SERVICES}; do
|
||||
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}-web:${TAG}"
|
||||
echo ""
|
||||
echo "Building ${PREFIX}-web -> ${IMAGE} (context: ./apps/infoalloggi)"
|
||||
|
||||
IMAGE="${IMAGE_REGISTRY}/${OWNER}/${PREFIX}-${svc}:${TAG}"
|
||||
echo ""
|
||||
echo "Building ${PREFIX}-${svc} -> ${IMAGE} (context: ${ctx})"
|
||||
|
||||
docker build \
|
||||
--build-arg ENV_FILE="${ENV_FILE}" \
|
||||
-t "${IMAGE}" \
|
||||
--label "org.opencontainers.image.description=${DESCRIPTION}" \
|
||||
-f "$ctx/$dockerfile" \
|
||||
"$ctx"
|
||||
|
||||
# Store the image name for later pushing
|
||||
BUILT_IMAGES+=("${IMAGE}")
|
||||
echo "✓ Built ${IMAGE}"
|
||||
done
|
||||
docker build \
|
||||
--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}" \
|
||||
--label "org.opencontainers.image.description=${DESCRIPTION}" \
|
||||
-f "./apps/infoalloggi/Dockerfile" \
|
||||
"./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"
|
||||
|
||||
BUILT_IMAGES+=("${IMAGE}")
|
||||
echo "✓ Built ${IMAGE}"
|
||||
|
||||
echo ""
|
||||
echo "================================"
|
||||
|
|
@ -105,4 +107,4 @@ echo "Images:"
|
|||
for IMAGE in "${BUILT_IMAGES[@]}"; do
|
||||
echo " - ${IMAGE}"
|
||||
done
|
||||
echo "================================"
|
||||
echo "================================"
|
||||
|
|
|
|||
|
|
@ -5,10 +5,9 @@ set -euo pipefail
|
|||
export TAG="latest"
|
||||
export IMAGE_REGISTRY="ghcr.io"
|
||||
export OWNER="marcopedone"
|
||||
export SERVICES="web backend"
|
||||
export USERNAME="marcopedone"
|
||||
export TOKEN="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"
|
||||
export ENV_FILE=".env.infoalloggi"
|
||||
export PREFIX="infoalloggi"
|
||||
|
||||
./build_and_push_ghcr.sh
|
||||
./build_and_push_ghcr.sh
|
||||
|
|
|
|||
|
|
@ -5,10 +5,9 @@ set -euo pipefail
|
|||
export TAG="latest"
|
||||
export IMAGE_REGISTRY="ghcr.io"
|
||||
export OWNER="marcopedone"
|
||||
export SERVICES="web backend"
|
||||
export USERNAME="marcopedone"
|
||||
export TOKEN="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"
|
||||
export ENV_FILE=".env.marcopedone"
|
||||
export PREFIX="marcopedone"
|
||||
|
||||
./build_and_push_ghcr.sh
|
||||
./build_and_push_ghcr.sh
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue