3 Commits

Author SHA1 Message Date
e22b3c82a2 Fix Docker build version detection
- Skip prebuild step in Docker when VERSION build arg is provided
- Prevent version-check.js from overwriting pre-generated version.js in Docker
- Fix Docker containers showing incorrect '-dev' suffix for release builds
- Use direct react-scripts build when version is pre-generated
2026-01-21 22:06:37 +01:00
c9ce0d14b9 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
2026-01-21 21:55:58 +01:00
ef2c1931d8 Fix Docker repository name in build script
- Update all Docker image references to use skoszewski/jmespath-playground
- Fix build.sh to create properly namespaced Docker images for Docker Hub
- Update Docker run command examples with correct repository name
2026-01-21 21:52:25 +01:00
4 changed files with 75 additions and 45 deletions

View File

@@ -31,8 +31,14 @@ RUN if [ -n "$VERSION" ]; then \
echo "📝 Generated version.js with VERSION=$VERSION, IS_RELEASE=$IS_RELEASE"; \ echo "📝 Generated version.js with VERSION=$VERSION, IS_RELEASE=$IS_RELEASE"; \
fi fi
# Build the application # Build the application (skip prebuild if we already generated version.js)
RUN npm run build RUN if [ -n "$VERSION" ]; then \
echo "🚀 Building with pre-generated version.js" && \
npx react-scripts build; \
else \
echo "🚀 Building with version-check.js" && \
npm run build; \
fi
# Production stage # Production stage
FROM node:24-alpine AS production FROM node:24-alpine AS production

View File

@@ -1,6 +1,6 @@
{ {
"name": "jmespath-playground", "name": "jmespath-playground",
"version": "1.1.3", "version": "1.1.6",
"description": "A React-based web application for testing JMESPath expressions against JSON data", "description": "A React-based web application for testing JMESPath expressions against JSON data",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

63
scripts/build-image.sh Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
# JMESPath Testing Tool - Docker Image Build Script
set -e
echo "🐳 JMESPath Testing Tool - Docker Image Build"
echo "=============================================="
echo ""
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo "❌ Docker not found. Please install Docker to build container images."
exit 1
fi
# 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"
echo ""
echo "To run the release container:"
echo " docker run -p 3000:3000 skoszewski/jmespath-playground:$VERSION"
echo " docker run -p 3000:3000 skoszewski/jmespath-playground:latest"
echo ""
echo "To push to Docker Hub:"
echo " docker push skoszewski/jmespath-playground:$VERSION"
echo " docker push 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"
echo ""
echo "To run the development container:"
echo " docker run -p 3000:3000 skoszewski/jmespath-playground:dev"
echo " docker run -p 3000:3000 skoszewski/jmespath-playground:latest"
echo ""
echo "To push to Docker Hub:"
echo " docker push skoszewski/jmespath-playground:dev"
echo " docker push skoszewski/jmespath-playground:latest"
fi
echo ""
echo "🎉 Docker image build completed successfully!"

View File

@@ -30,49 +30,10 @@ npm install
echo "🔨 Building production bundle..." echo "🔨 Building production bundle..."
npm run build 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 jmespath-playground:$VERSION \
-t jmespath-playground:latest .
echo "✅ Built Docker images: jmespath-playground:$VERSION, 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 jmespath-playground:dev \
-t jmespath-playground:latest .
echo "✅ Built Docker images: jmespath-playground:dev, 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 "✅ Build completed successfully!"
echo "" echo ""
echo "To run the application:" echo "To run the application:"
echo " npm run server # Run integrated server locally" echo " npm run server # Run integrated server locally"
if command -v docker &> /dev/null; then echo ""
VERSION=$(git tag --points-at HEAD 2>/dev/null | sed 's/^v//' | head -n 1) echo "To build Docker image:"
if [ -n "$VERSION" ]; then echo " scripts/build-image.sh # Build Docker container image"
echo " docker run -p 3000:3000 jmespath-playground:$VERSION # Run release container"
else
echo " docker run -p 3000:3000 jmespath-playground:dev # Run dev container"
fi
echo " docker run -p 3000:3000 jmespath-playground:latest # Run latest container"
fi