refactor: Update Docker setup and Makefile for improved development workflow

This commit is contained in:
sHa
2025-04-28 09:52:08 +03:00
parent 9e4fd4290f
commit e2614693fd
4 changed files with 32 additions and 74 deletions

View File

@@ -25,7 +25,7 @@ No local Node.js installation is required as all operations run inside Docker co
make start
```
3. Access the application at http://localhost:5005
3. Access the application at http://localhost:5006
## Common Development Tasks
@@ -72,24 +72,33 @@ logos/
│ ├── App.svelte # Main app component
│ └── main.js # App entry point
├── scripts/ # Utility scripts
├── Dockerfile # Docker configuration
├── compose.yml # Docker Compose configuration
├── Dockerfile.dev # Docker configuration for development
├── compose.dev.yml # Docker Compose configuration for development
├── Makefile # Development commands
└── README.md # Project overview
```
## Deployment to GitHub Pages
To deploy the application to GitHub Pages:
Deployment is fully automated using GitHub Actions. On every push to the `main` branch:
1. Build the application:
```
make build
```
1. The application is built in a GitHub Actions workflow.
2. The build output and all required static assets are prepared as an artifact.
3. The workflow deploys the site to the `gh-pages` branch using the official GitHub Pages deployment action.
4. If a custom domain is configured, the `CNAME` file is included automatically.
2. The `public/` directory contains all files needed for deployment
**You do not need to manually build or push anything for deployment.**
3. Push the contents of the `public/` directory to the `gh-pages` branch of your repository
To trigger a deployment, simply push your changes to the `main` branch:
```
git add .
git commit -m "Your changes"
git push
```
You can monitor deployment status in the GitHub Actions tab of your repository.
For custom domain setup, ensure your `public/CNAME` file contains your domain and your DNS is configured to point to GitHub Pages.
## Available Make Commands

View File

@@ -1,26 +0,0 @@
FROM node:slim
# Update package index and upgrade packages to reduce vulnerabilities
RUN apt-get update && apt-get upgrade -y
WORKDIR /app
COPY package*.json ./
RUN npm install
# Copy all source files except those in .dockerignore
COPY . .
# Create necessary directories for the build
RUN mkdir -p public/build
RUN mkdir -p public/data
# Build the application
RUN npm run build
EXPOSE 5000
EXPOSE 35729
# Start the server
CMD ["npm", "run", "start"]

View File

@@ -3,11 +3,10 @@
# Configuration
DOCKER_COMPOSE = docker compose
CONTAINER_NAME = logo-gallery
PORT = 5005
DEV_PORT = 5006
# Main targets
.PHONY: all build start stop restart logs clean scan-logos-dev help dev
.PHONY: all build start stop restart logs clean scan-logos-dev dev
all: build start
@@ -18,18 +17,18 @@ dev:
# Build the Docker container
build:
@echo "Building the Logo Gallery container..."
$(DOCKER_COMPOSE) build
$(DOCKER_COMPOSE) -f compose.dev.yml build
# Start the application in the background
start:
@echo "Starting Logo Gallery application on port $(PORT)..."
$(DOCKER_COMPOSE) up -d
@echo "Application is running at http://localhost:$(PORT)"
@echo "Starting Logo Gallery application on port $(DEV_PORT)..."
$(DOCKER_COMPOSE) -f compose.dev.yml up -d
@echo "Application is running at http://localhost:$(DEV_PORT)"
# Stop the application
stop:
@echo "Stopping Logo Gallery application..."
$(DOCKER_COMPOSE) down
$(DOCKER_COMPOSE) -f compose.dev.yml down
# Restart the application
restart: stop start
@@ -37,13 +36,13 @@ restart: stop start
# View the application logs
logs:
@echo "Showing application logs (press Ctrl+C to exit)..."
$(DOCKER_COMPOSE) logs -f
$(DOCKER_COMPOSE) -f compose.dev.yml logs -f
# Run a command inside the container
# Usage: make run CMD="npm run build"
run:
@echo "Running command in container: $(CMD)"
$(DOCKER_COMPOSE) run --rm $(CONTAINER_NAME) $(CMD)
$(DOCKER_COMPOSE) -f compose.dev.yml run --rm $(CONTAINER_NAME) $(CMD)
# Scan logos.json from files in the logos directory (for dev mode)
scan-logos-dev:
@@ -54,28 +53,14 @@ scan-logos-dev:
# Clean up build artifacts and temporary files
clean:
@echo "Cleaning up build artifacts and temporary files..."
$(DOCKER_COMPOSE) down
$(DOCKER_COMPOSE) -f compose.dev.yml down
docker builder prune -f
# Complete rebuild from scratch
rebuild:
@echo "Performing complete rebuild..."
$(DOCKER_COMPOSE) down
$(DOCKER_COMPOSE) -f compose.dev.yml down
docker builder prune -f
$(DOCKER_COMPOSE) build --no-cache
$(DOCKER_COMPOSE) up -d
@echo "Rebuild complete. Application is running at http://localhost:$(PORT)"
# Display help information
help:
@echo "Logo Gallery Makefile commands:"
@echo " make build - Build the Docker container"
@echo " make start - Start the application (http://localhost:$(PORT))"
@echo " make stop - Stop the application"
@echo " make restart - Restart the application"
@echo " make logs - View the application logs"
@echo " make run CMD=<cmd> - Run a command in the container"
@echo " make scan-logos-dev - Scan logos.json from assets directory"
@echo " make clean - Clean up build artifacts"
@echo " make rebuild - Completely rebuild from scratch"
@echo " make help - Display this help information"
$(DOCKER_COMPOSE) -f compose.dev.yml build --no-cache
$(DOCKER_COMPOSE) -f compose.dev.yml up -d
@echo "Rebuild complete. Application is running at http://localhost:$(DEV_PORT)"

View File

@@ -1,10 +0,0 @@
services:
logo-gallery:
build: .
container_name: logo-gallery
ports:
- "5005:5000" # App port
- "35729:35729" # LiveReload port
environment:
- NODE_ENV=development
- HOST=0.0.0.0