refactor: remove legacy support from Docker and Makefile
Dockerfile changes: - Replace pip with uv package manager for faster builds - Remove build-essential and git dependencies - Use pyproject.toml instead of requirements.txt - Add uv installation and virtual environment setup - Modernize environment variables and caching - Fix hadolint warnings (add --no-install-recommends and pipefail) Makefile changes: - Remove docker-build-legacy target (legacy builder) - Remove docker-dev-host and docker-prod-host targets (networking workarounds) - Remove docker-reset target (networking fixes) - Remove docker-clean-legacy target (duplicate functionality) - Clean up help output and reduce maintenance overhead This modernizes the build system and removes workarounds for older Docker versions and networking issues.
This commit is contained in:
29
Dockerfile
29
Dockerfile
@@ -1,21 +1,24 @@
|
|||||||
# UnitForge Docker Image
|
# UnitForge Docker Image
|
||||||
# Simple build for development and production
|
# Modern build for development and production
|
||||||
|
|
||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
ENV PYTHONUNBUFFERED=1 \
|
ENV PYTHONUNBUFFERED=1 \
|
||||||
PYTHONDONTWRITEBYTECODE=1 \
|
PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PIP_NO_CACHE_DIR=1 \
|
UV_CACHE_DIR=/tmp/uv-cache \
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
UV_PYTHON=python3
|
||||||
|
|
||||||
# Install system dependencies
|
# Install system dependencies and uv
|
||||||
RUN apt-get update && apt-get install -y \
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
curl \
|
curl \
|
||||||
git \
|
&& curl -LsSf https://astral.sh/uv/install.sh | sh \
|
||||||
build-essential \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Add uv to PATH
|
||||||
|
ENV PATH="/root/.cargo/bin:$PATH"
|
||||||
|
|
||||||
# Create app user
|
# Create app user
|
||||||
RUN groupadd --gid 1000 app && \
|
RUN groupadd --gid 1000 app && \
|
||||||
useradd --uid 1000 --gid app --shell /bin/bash --create-home app
|
useradd --uid 1000 --gid app --shell /bin/bash --create-home app
|
||||||
@@ -23,9 +26,12 @@ RUN groupadd --gid 1000 app && \
|
|||||||
# Set work directory
|
# Set work directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy dependency files and install Python dependencies
|
# Copy dependency files
|
||||||
COPY backend/requirements.txt backend/
|
COPY pyproject.toml uv.lock ./
|
||||||
RUN pip install --no-cache-dir -r backend/requirements.txt
|
|
||||||
|
# Install dependencies with uv
|
||||||
|
RUN uv venv && \
|
||||||
|
uv pip install -e ".[web]"
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -38,6 +44,9 @@ RUN chown -R app:app /app
|
|||||||
|
|
||||||
USER app
|
USER app
|
||||||
|
|
||||||
|
# Activate virtual environment
|
||||||
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Default command for development
|
# Default command for development
|
||||||
|
|||||||
24
Makefile
24
Makefile
@@ -277,29 +277,18 @@ docker-login: ## Login to container registry (interactive)
|
|||||||
fi
|
fi
|
||||||
$(call success,Logged into container registry)
|
$(call success,Logged into container registry)
|
||||||
|
|
||||||
docker-build-legacy: ## Build Docker images with legacy builder (networking issues workaround)
|
|
||||||
$(call info,Building Docker images with legacy builder...)
|
|
||||||
DOCKER_BUILDKIT=0 docker-compose build
|
|
||||||
$(call success,Docker images built with legacy builder)
|
|
||||||
|
|
||||||
docker-dev: ## Start development environment with Docker
|
docker-dev: ## Start development environment with Docker
|
||||||
$(call info,Starting development environment with Docker...)
|
$(call info,Starting development environment with Docker...)
|
||||||
docker-compose up unitforge-dev
|
docker-compose up unitforge-dev
|
||||||
|
|
||||||
docker-dev-host: ## Start development environment with host networking (networking issues workaround)
|
|
||||||
$(call info,Starting development environment with host networking...)
|
|
||||||
docker-compose -f docker-compose.yml -f docker-compose.host-network.yml up unitforge-dev
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
docker-prod: ## Start production environment with Docker
|
docker-prod: ## Start production environment with Docker
|
||||||
$(call info,Starting production environment with Docker...)
|
$(call info,Starting production environment with Docker...)
|
||||||
docker-compose up unitforge-prod
|
docker-compose up unitforge-prod
|
||||||
|
|
||||||
docker-prod-host: ## Start production environment with host networking (networking issues workaround)
|
|
||||||
$(call info,Starting production environment with host networking...)
|
|
||||||
docker-compose -f docker-compose.yml -f docker-compose.host-network.yml up unitforge-prod
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
docker-cli: ## Run CLI in Docker
|
docker-cli: ## Run CLI in Docker
|
||||||
@@ -320,18 +309,7 @@ docker-clean: ## Clean up Docker containers and volumes
|
|||||||
docker system prune -f
|
docker system prune -f
|
||||||
$(call success,Docker cleanup completed)
|
$(call success,Docker cleanup completed)
|
||||||
|
|
||||||
docker-reset: ## Reset Docker networking (fix networking issues)
|
|
||||||
$(call info,Resetting Docker networking...)
|
|
||||||
docker network prune -f
|
|
||||||
docker system prune -f
|
|
||||||
sudo systemctl restart docker || echo "Could not restart Docker daemon (requires sudo)"
|
|
||||||
$(call success,Docker networking reset completed)
|
|
||||||
|
|
||||||
docker-clean-legacy: ## Clean Docker containers and images
|
|
||||||
$(call info,Cleaning Docker containers and images...)
|
|
||||||
docker-compose down --volumes --remove-orphans
|
|
||||||
docker system prune -f
|
|
||||||
$(call success,Docker cleanup complete)
|
|
||||||
|
|
||||||
docker-clean-registry: ## Remove locally cached registry images
|
docker-clean-registry: ## Remove locally cached registry images
|
||||||
$(call info,Cleaning registry images from local cache...)
|
$(call info,Cleaning registry images from local cache...)
|
||||||
|
|||||||
Reference in New Issue
Block a user