Init working UI
This commit is contained in:
97
makefile
97
makefile
@@ -1,64 +1,97 @@
|
||||
.PHONY: install build start dev clean docker-build docker-run docker-stop
|
||||
.PHONY: install build start dev clean docker-build docker-dev docker-prod docker-stop docker-rebuild-dev docker-rebuild-prod
|
||||
|
||||
# Define variables
|
||||
APP_NAME := drb-frontend
|
||||
DOCKER_IMAGE_NAME := $(APP_NAME):latest
|
||||
DOCKER_CONTAINER_NAME := $(APP_NAME)-container
|
||||
DOCKER_DEV_CONTAINER_NAME := $(APP_NAME)-dev-container
|
||||
DOCKER_PROD_CONTAINER_NAME := $(APP_NAME)-prod-container
|
||||
|
||||
# Default target when `make` is run without arguments
|
||||
# --- Local Development and Build ---
|
||||
|
||||
# Default target
|
||||
all: dev
|
||||
|
||||
# Install Node.js dependencies
|
||||
install:
|
||||
@echo "Installing Node.js dependencies..."
|
||||
@echo "➡️ Installing Node.js dependencies..."
|
||||
npm install
|
||||
|
||||
# Build the Next.js application for production
|
||||
build: install
|
||||
@echo "Building Next.js application for production..."
|
||||
@echo "➡️ Building Next.js application for production..."
|
||||
npm run build
|
||||
|
||||
# Start the Next.js application in production mode
|
||||
# Start the Next.js application in production mode (locally)
|
||||
start: build
|
||||
@echo "Starting Next.js application in production mode..."
|
||||
@echo "➡️ Starting Next.js application in production mode locally..."
|
||||
npm start
|
||||
|
||||
# Start the Next.js application in development mode
|
||||
# Start the Next.js application in development mode (locally)
|
||||
dev: install
|
||||
@echo "Starting Next.js application in development mode..."
|
||||
@echo "➡️ Starting Next.js application in development mode locally (Fast Refresh enabled)..."
|
||||
npm run dev
|
||||
|
||||
# Clean up build artifacts and node_modules
|
||||
clean:
|
||||
@echo "Cleaning up build artifacts and node_modules..."
|
||||
@echo "➡️ Cleaning up build artifacts and node_modules..."
|
||||
rm -rf .next out node_modules
|
||||
@echo "Clean up complete."
|
||||
@echo "✅ Clean up complete."
|
||||
|
||||
# --- Docker Operations ---
|
||||
|
||||
# Build the Docker image
|
||||
docker-build:
|
||||
@echo "Building Docker image: $(DOCKER_IMAGE_NAME)..."
|
||||
@echo "🐳 Building Docker image: $(DOCKER_IMAGE_NAME)..."
|
||||
docker build -t $(DOCKER_IMAGE_NAME) .
|
||||
@echo "Docker image built successfully."
|
||||
@echo "✅ Docker image built successfully."
|
||||
|
||||
# Run the Docker container
|
||||
docker-run: docker-build
|
||||
@echo "Running Docker container: $(DOCKER_CONTAINER_NAME)..."
|
||||
docker run -it --rm --name $(DOCKER_CONTAINER_NAME) -p 3000:3000 $(DOCKER_IMAGE_NAME)
|
||||
@echo "Docker container started. Access at http://localhost:3000"
|
||||
# Run the Docker container in development mode
|
||||
docker-dev: #docker-build
|
||||
@echo "🚀 Running Docker container in DEVELOPMENT mode: $(DOCKER_DEV_CONTAINER_NAME)..."
|
||||
@echo " (Volume mounted for Fast Refresh: $(PWD):/app)"
|
||||
# Ensure node_modules is also mounted, as it's typically excluded from the main volume mount
|
||||
# to avoid issues with host OS vs. container OS binary compatibility.
|
||||
# The bind mount for node_modules effectively hides the one from the image.
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
--name $(DOCKER_DEV_CONTAINER_NAME) \
|
||||
-p 3000:3000 \
|
||||
-v "$(PWD):/app" \
|
||||
-v "/app/node_modules" \
|
||||
-e NODE_ENV=development \
|
||||
$(DOCKER_IMAGE_NAME)
|
||||
@echo "✨ Docker container started in development. Access at http://localhost:3000"
|
||||
|
||||
# Run the Docker container
|
||||
docker-deploy: docker-build
|
||||
@echo "Running Docker container: $(DOCKER_CONTAINER_NAME)..."
|
||||
docker run -d --rm --name $(DOCKER_CONTAINER_NAME) -p 3000:3000 $(DOCKER_IMAGE_NAME)
|
||||
@echo "Docker container started. Access at http://localhost:3000"
|
||||
|
||||
# Stop and remove the Docker container
|
||||
docker-stop:
|
||||
@echo "Stopping and removing Docker container: $(DOCKER_CONTAINER_NAME)..."
|
||||
docker stop $(DOCKER_CONTAINER_NAME) || true
|
||||
docker rm $(DOCKER_CONTAINER_NAME) || true
|
||||
@echo "Docker container stopped and removed."
|
||||
# Run the Docker container in production mode
|
||||
docker-prod: docker-build docker-stop-prod
|
||||
@echo "🚀 Running Docker container in PRODUCTION mode: $(DOCKER_PROD_CONTAINER_NAME)..."
|
||||
docker run -d --rm --name $(DOCKER_PROD_CONTAINER_NAME) -p 3000:3000 $(DOCKER_IMAGE_NAME)
|
||||
@echo "✅ Docker container started in production. Access at http://localhost:3000"
|
||||
|
||||
# Optional: Rebuild and rerun the Docker container
|
||||
docker-rebuild-run: docker-stop docker-run
|
||||
@echo "Rebuilding and rerunning Docker container."
|
||||
# Stop and remove the DEVELOPMENT Docker container
|
||||
docker-stop-dev:
|
||||
@echo "🛑 Stopping and removing DEVELOPMENT Docker container: $(DOCKER_DEV_CONTAINER_NAME)..."
|
||||
-docker stop $(DOCKER_DEV_CONTAINER_NAME) 2>/dev/null || true
|
||||
-docker rm $(DOCKER_DEV_CONTAINER_NAME) 2>/dev/null || true
|
||||
@echo "✅ Development Docker container stopped and removed (if it was running)."
|
||||
|
||||
# Stop and remove the PRODUCTION Docker container
|
||||
docker-stop-prod:
|
||||
@echo "🛑 Stopping and removing PRODUCTION Docker container: $(DOCKER_PROD_CONTAINER_NAME)..."
|
||||
-docker stop $(DOCKER_PROD_CONTAINER_NAME) 2>/dev/null || true
|
||||
-docker rm $(DOCKER_PROD_CONTAINER_NAME) 2>/dev/null || true
|
||||
@echo "✅ Production Docker container stopped and removed (if it was running)."
|
||||
|
||||
# Stop and remove ALL Docker containers related to this app
|
||||
docker-stop-all: docker-stop-dev docker-stop-prod
|
||||
@echo "🛑 Stopped all active containers for $(APP_NAME)."
|
||||
|
||||
# Rebuild and rerun the Docker container in development mode
|
||||
docker-rebuild-dev: docker-build docker-dev
|
||||
@echo "🔄 Rebuilding and rerunning Docker container in development."
|
||||
|
||||
# Rebuild and rerun the Docker container in production mode
|
||||
docker-rebuild-prod: docker-build docker-prod
|
||||
@echo "🔄 Rebuilding and rerunning Docker container in production."
|
||||
Reference in New Issue
Block a user