feat: Add APP_NAME env support for branding and deployment
- Make app name configurable via APP_NAME env variable - Update UI, HTML, Docker, scripts, and k8s to use APP_NAME - Add process-html.sh for template substitution - Document APP_NAME usage in docs/APP_NAME_CONFIGURATION.md - Update Dockerfile, compose, and scripts for dynamic naming - Add index.html.template for environment-based branding
This commit is contained in:
@@ -34,9 +34,10 @@ print_error() {
|
||||
# Cleanup function
|
||||
cleanup() {
|
||||
print_status "Cleaning up test containers..."
|
||||
docker stop meds-validation-test 2>/dev/null || true
|
||||
docker rm meds-validation-test 2>/dev/null || true
|
||||
docker compose -f docker/docker-compose.yaml -p meds-validation down 2>/dev/null || true
|
||||
APP_NAME_LOWER=$(echo "${APP_NAME:-meds}" | tr '[:upper:]' '[:lower:]')
|
||||
docker stop ${APP_NAME_LOWER}-validation-test 2>/dev/null || true
|
||||
docker rm ${APP_NAME_LOWER}-validation-test 2>/dev/null || true
|
||||
docker compose -f docker/docker-compose.yaml -p ${APP_NAME_LOWER}-validation down 2>/dev/null || true
|
||||
}
|
||||
|
||||
# Set trap for cleanup
|
||||
@@ -81,8 +82,12 @@ docker buildx use meds-builder
|
||||
print_status "4. Building multi-platform Docker image with buildx..."
|
||||
|
||||
# Build the image with buildx for multiple platforms
|
||||
# Build single-platform image for testing
|
||||
print_status "Building single-platform Docker image for testing..."
|
||||
APP_NAME_LOWER=$(echo "${APP_NAME:-meds}" | tr '[:upper:]' '[:lower:]')
|
||||
docker buildx build --no-cache \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--platform "$HOST_PLATFORM" \
|
||||
--build-arg APP_NAME="${APP_NAME:-RxMinder}" \
|
||||
--build-arg COUCHDB_USER="${COUCHDB_USER:-admin}" \
|
||||
--build-arg COUCHDB_PASSWORD="${COUCHDB_PASSWORD:-change-this-secure-password}" \
|
||||
--build-arg VITE_COUCHDB_URL="${VITE_COUCHDB_URL:-http://localhost:5984}" \
|
||||
@@ -95,7 +100,7 @@ docker buildx build --no-cache \
|
||||
--build-arg MAILGUN_DOMAIN="${MAILGUN_DOMAIN:-}" \
|
||||
--build-arg MAILGUN_FROM_EMAIL="${MAILGUN_FROM_EMAIL:-}" \
|
||||
--build-arg NODE_ENV="${NODE_ENV:-production}" \
|
||||
-t meds-validation \
|
||||
-t ${APP_NAME_LOWER}-validation \
|
||||
--load \
|
||||
.
|
||||
|
||||
@@ -106,16 +111,16 @@ print_status "5. Testing container startup and health..."
|
||||
# Run container in background
|
||||
docker run --rm -d \
|
||||
-p 8083:80 \
|
||||
--name meds-validation-test \
|
||||
meds-validation
|
||||
--name ${APP_NAME_LOWER}-validation-test \
|
||||
${APP_NAME_LOWER}-validation
|
||||
|
||||
# Wait for container to start
|
||||
sleep 5
|
||||
|
||||
# Check if container is running
|
||||
if ! docker ps | grep -q meds-validation-test; then
|
||||
if ! docker ps | grep -q ${APP_NAME_LOWER}-validation-test; then
|
||||
print_error "Container failed to start"
|
||||
docker logs meds-validation-test
|
||||
docker logs ${APP_NAME_LOWER}-validation-test
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -154,17 +159,17 @@ print_success "Docker Compose build successful"
|
||||
|
||||
# Test docker-compose with validation project name
|
||||
print_status "8. Testing Docker Compose deployment..."
|
||||
docker compose -f docker/docker-compose.yaml -p meds-validation up -d --build
|
||||
docker compose -f docker/docker-compose.yaml -p ${APP_NAME_LOWER}-validation up -d --build
|
||||
|
||||
# Wait for services to start
|
||||
sleep 10
|
||||
|
||||
# Check service health
|
||||
if docker compose -f docker/docker-compose.yaml -p meds-validation ps | grep -q "Up"; then
|
||||
if docker compose -f docker/docker-compose.yaml -p ${APP_NAME_LOWER}-validation ps | grep -q "Up"; then
|
||||
print_success "Docker Compose services started successfully"
|
||||
else
|
||||
print_error "Docker Compose services failed to start"
|
||||
docker compose -f docker/docker-compose.yaml -p meds-validation logs
|
||||
docker compose -f docker/docker-compose.yaml -p ${APP_NAME_LOWER}-validation logs
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -176,13 +181,13 @@ else
|
||||
fi
|
||||
|
||||
print_status "9. Checking image size..."
|
||||
IMAGE_SIZE=$(docker image inspect meds-validation --format='{{.Size}}' | numfmt --to=iec)
|
||||
IMAGE_SIZE=$(docker image inspect ${APP_NAME_LOWER}-validation --format='{{.Size}}' | numfmt --to=iec)
|
||||
print_success "Image size: $IMAGE_SIZE"
|
||||
|
||||
print_status "10. Validating security configuration..."
|
||||
|
||||
# Check if image runs as non-root
|
||||
USER_INFO=$(docker run --rm meds-validation whoami)
|
||||
USER_INFO=$(docker run --rm ${APP_NAME_LOWER}-validation whoami)
|
||||
if [[ "$USER_INFO" != "root" ]]; then
|
||||
print_success "Container runs as non-root user: $USER_INFO"
|
||||
else
|
||||
@@ -190,7 +195,7 @@ else
|
||||
fi
|
||||
|
||||
# Check nginx configuration
|
||||
if docker run --rm meds-validation nginx -t 2>/dev/null; then
|
||||
if docker run --rm ${APP_NAME_LOWER}-validation nginx -t 2>/dev/null; then
|
||||
print_success "Nginx configuration is valid"
|
||||
else
|
||||
print_error "Nginx configuration has issues"
|
||||
|
||||
Reference in New Issue
Block a user