109 lines
3.1 KiB
Bash
109 lines
3.1 KiB
Bash
#!/bin/bash
|
|
|
|
# ============================================================================
|
|
# CONFIGURATION - Modify these for your project
|
|
# ============================================================================
|
|
|
|
# Docker registry and image name
|
|
DOCKER_REPO="docker.site.quack-lab.dev"
|
|
IMAGE_NAME="eveship-fit"
|
|
|
|
# ============================================================================
|
|
# CHECK IF PACKAGES ARE PUBLISHED
|
|
# ============================================================================
|
|
|
|
echo "Note: Make sure all packages are published to your Gitea registry first!"
|
|
echo "Build order:"
|
|
echo " 1. ./eveship.fit.data/build.sh"
|
|
echo " 2. ./eveship.fit.dogma.engine/build.sh"
|
|
echo " 3. ./eveship.fit.react/build.sh"
|
|
echo "Then run this script for the main app."
|
|
echo ""
|
|
|
|
# ============================================================================
|
|
# INSTALL DEPENDENCIES
|
|
# ============================================================================
|
|
|
|
echo "Installing dependencies..."
|
|
bun install --frozen-lockfile
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error installing dependencies"
|
|
exit 1
|
|
fi
|
|
|
|
|
|
# ============================================================================
|
|
# BUILD PROJECT
|
|
# ============================================================================
|
|
|
|
echo "Building application..."
|
|
bun run build
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error building application"
|
|
exit 1
|
|
fi
|
|
|
|
# ============================================================================
|
|
# DOCKER BUILD AND TAG
|
|
# ============================================================================
|
|
|
|
COMMIT_SHA=$(git rev-parse --short HEAD)
|
|
IMAGE_BASE="${DOCKER_REPO}/${IMAGE_NAME}"
|
|
|
|
echo ""
|
|
echo "Building Docker image..."
|
|
docker build --build-arg NPM_TOKEN="${NPM_TOKEN:-}" -t "${IMAGE_BASE}:${COMMIT_SHA}" .
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error building agx Docker image"
|
|
exit 1
|
|
fi
|
|
|
|
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 ""
|
|
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 ""
|
|
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 |