74 lines
2.1 KiB
Bash
74 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# ============================================================================
|
|
# CONFIGURATION - Modify these for your project
|
|
# ============================================================================
|
|
|
|
# Docker registry and image name
|
|
DOCKER_REPO="docker.site.quack-lab.dev"
|
|
IMAGE_NAME="journal-fe"
|
|
|
|
# ============================================================================
|
|
# BUILD PROJECT
|
|
# ============================================================================
|
|
|
|
echo "Building project..."
|
|
bun run build
|
|
|
|
# ============================================================================
|
|
# DOCKER BUILD AND TAG
|
|
# ============================================================================
|
|
|
|
COMMIT_SHA=$(git rev-parse --short HEAD)
|
|
IMAGE_BASE="${DOCKER_REPO}/${IMAGE_NAME}"
|
|
|
|
echo "Building Docker image..."
|
|
docker build -t "${IMAGE_BASE}:${COMMIT_SHA}" .
|
|
|
|
echo "Tagging as latest..."
|
|
docker tag "${IMAGE_BASE}:${COMMIT_SHA}" "${IMAGE_BASE}:latest"
|
|
|
|
TAGS=$(git tag --points-at HEAD)
|
|
if [ -n "$TAGS" ]; then
|
|
echo "Found tags on current commit:"
|
|
while IFS= read -r tag; do
|
|
if [ -n "$tag" ]; then
|
|
echo "Tagging as ${tag}..."
|
|
docker tag "${IMAGE_BASE}:${COMMIT_SHA}" "${IMAGE_BASE}:${tag}"
|
|
fi
|
|
done <<< "$TAGS"
|
|
fi
|
|
|
|
# ============================================================================
|
|
# PUSH IMAGES
|
|
# ============================================================================
|
|
|
|
echo "Pushing Docker images..."
|
|
docker push "${IMAGE_BASE}:${COMMIT_SHA}"
|
|
docker push "${IMAGE_BASE}:latest"
|
|
|
|
if [ -n "$TAGS" ]; then
|
|
while IFS= read -r tag; do
|
|
if [ -n "$tag" ]; then
|
|
docker push "${IMAGE_BASE}:${tag}"
|
|
fi
|
|
done <<< "$TAGS"
|
|
fi
|
|
|
|
# ============================================================================
|
|
# SUMMARY
|
|
# ============================================================================
|
|
|
|
echo "Build complete! Image pushed as:"
|
|
echo " - ${IMAGE_BASE}:${COMMIT_SHA}"
|
|
echo " - ${IMAGE_BASE}:latest"
|
|
if [ -n "$TAGS" ]; then
|
|
while IFS= read -r tag; do
|
|
if [ -n "$tag" ]; then
|
|
echo " - ${IMAGE_BASE}:${tag}"
|
|
fi
|
|
done <<< "$TAGS"
|
|
fi
|