65 lines
2.0 KiB
Makefile
65 lines
2.0 KiB
Makefile
.PHONY: install build start dev clean docker-build docker-run docker-stop
|
|
|
|
# Define variables
|
|
APP_NAME := drb-frontend
|
|
DOCKER_IMAGE_NAME := $(APP_NAME):latest
|
|
DOCKER_CONTAINER_NAME := $(APP_NAME)-container
|
|
|
|
# Default target when `make` is run without arguments
|
|
all: dev
|
|
|
|
# Install Node.js dependencies
|
|
install:
|
|
@echo "Installing Node.js dependencies..."
|
|
npm install
|
|
|
|
# Build the Next.js application for production
|
|
build: install
|
|
@echo "Building Next.js application for production..."
|
|
npm run build
|
|
|
|
# Start the Next.js application in production mode
|
|
start: build
|
|
@echo "Starting Next.js application in production mode..."
|
|
npm start
|
|
|
|
# Start the Next.js application in development mode
|
|
dev: install
|
|
@echo "Starting Next.js application in development mode..."
|
|
npm run dev
|
|
|
|
# Clean up build artifacts and node_modules
|
|
clean:
|
|
@echo "Cleaning up build artifacts and node_modules..."
|
|
rm -rf .next out node_modules
|
|
@echo "Clean up complete."
|
|
|
|
# Build the Docker image
|
|
docker-build:
|
|
@echo "Building Docker image: $(DOCKER_IMAGE_NAME)..."
|
|
docker build -t $(DOCKER_IMAGE_NAME) .
|
|
@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
|
|
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."
|
|
|
|
# Optional: Rebuild and rerun the Docker container
|
|
docker-rebuild-run: docker-stop docker-run
|
|
@echo "Rebuilding and rerunning Docker container."
|