Separate Docker build into dedicated script

- Create build-image.sh for dedicated Docker image building
- Remove Docker build logic from build.sh to focus on Node.js app only
- Add comprehensive instructions for running and pushing Docker images
- Improve build script modularity and separation of concerns
This commit is contained in:
2026-01-21 21:55:58 +01:00
parent ef2c1931d8
commit c9ce0d14b9
3 changed files with 67 additions and 43 deletions

View File

@@ -30,49 +30,10 @@ npm install
echo "🔨 Building production bundle..."
npm run build
# Optional container build with Docker
if command -v docker &> /dev/null; then
echo "🐳 Building Docker container (optional)..."
# Determine version information for Docker build
VERSION=$(git tag --points-at HEAD 2>/dev/null | sed 's/^v//' | head -n 1)
if [ -n "$VERSION" ]; then
# We're at a tagged commit - release build
echo "📦 Building release version: $VERSION"
docker build \
--build-arg VERSION="$VERSION" \
--build-arg IS_RELEASE="true" \
-t skoszewski/jmespath-playground:$VERSION \
-t skoszewski/jmespath-playground:latest .
echo "✅ Built Docker images: skoszewski/jmespath-playground:$VERSION, skoszewski/jmespath-playground:latest"
else
# Development build
PACKAGE_VERSION=$(grep '"version"' package.json | cut -d'"' -f4)
DEV_VERSION="${PACKAGE_VERSION}-dev"
echo "📦 Building development version: $DEV_VERSION"
docker build \
--build-arg VERSION="$DEV_VERSION" \
--build-arg IS_RELEASE="false" \
-t skoszewski/jmespath-playground:dev \
-t skoszewski/jmespath-playground:latest .
echo "✅ Built Docker images: skoszewski/jmespath-playground:dev, skoszewski/jmespath-playground:latest"
fi
else
echo "💡 Docker not found. Container build is optional."
echo " Install Docker if you want to build containers."
fi
echo "✅ Build completed successfully!"
echo ""
echo "To run the application:"
echo " npm run server # Run integrated server locally"
if command -v docker &> /dev/null; then
VERSION=$(git tag --points-at HEAD 2>/dev/null | sed 's/^v//' | head -n 1)
if [ -n "$VERSION" ]; then
echo " docker run -p 3000:3000 skoszewski/jmespath-playground:$VERSION # Run release container"
else
echo " docker run -p 3000:3000 skoszewski/jmespath-playground:dev # Run dev container"
fi
echo " docker run -p 3000:3000 skoszewski/jmespath-playground:latest # Run latest container"
fi
echo ""
echo "To build Docker image:"
echo " scripts/build-image.sh # Build Docker container image"