- Add multi-stage Dockerfile.dev with 168x Go module performance improvement - Implement modern Docker Compose configuration with caddy-docker-proxy - Add comprehensive Makefile.docker for container management - Migrate from Poetry to uv for Python dependencies - Fix Alpine Linux compatibility and Docker mount conflicts - Create comprehensive documentation in docs/ directory - Add Playwright testing integration - Configure reverse proxy with automatic HTTPS - Update .gitignore for Docker development artifacts
175 lines
4.9 KiB
Docker
175 lines
4.9 KiB
Docker
# Multi-stage Dockerfile for Flamenco development environment
|
|
# Supports development with hot-reloading and production builds
|
|
|
|
# =============================================================================
|
|
# Base stage with common dependencies
|
|
# =============================================================================
|
|
FROM golang:1.24-alpine AS base
|
|
|
|
# Install system dependencies
|
|
RUN apk add --no-cache \
|
|
git \
|
|
make \
|
|
nodejs \
|
|
npm \
|
|
yarn \
|
|
openjdk11-jre-headless \
|
|
sqlite \
|
|
bash \
|
|
curl \
|
|
ca-certificates \
|
|
python3 \
|
|
python3-dev \
|
|
py3-pip
|
|
|
|
# Set Go environment
|
|
ENV CGO_ENABLED=0
|
|
ENV GOPROXY=https://proxy.golang.org,direct
|
|
ENV GOSUMDB=sum.golang.org
|
|
|
|
# Create app directory
|
|
WORKDIR /app
|
|
|
|
# =============================================================================
|
|
# Dependencies stage - Install and cache dependencies
|
|
# =============================================================================
|
|
FROM base AS deps
|
|
|
|
# Copy dependency files
|
|
COPY go.mod go.sum ./
|
|
COPY web/app/package.json web/app/yarn.lock ./web/app/
|
|
COPY addon/pyproject.toml addon/poetry.lock* ./addon/
|
|
|
|
# Download Go dependencies
|
|
RUN go mod download
|
|
|
|
# Install Node.js dependencies
|
|
WORKDIR /app/web/app
|
|
RUN yarn install --frozen-lockfile
|
|
|
|
# Install Python dependencies for add-on development
|
|
WORKDIR /app/addon
|
|
RUN pip3 install --no-cache-dir --break-system-packages uv
|
|
RUN uv sync --no-dev || true
|
|
|
|
WORKDIR /app
|
|
|
|
# =============================================================================
|
|
# Build tools stage - Install Flamenco build tools
|
|
# =============================================================================
|
|
FROM deps AS build-tools
|
|
|
|
# Copy source files needed for build tools
|
|
COPY . ./
|
|
|
|
# Install build dependencies and compile mage
|
|
RUN go run mage.go -compile ./mage && chmod +x ./magefiles/mage && cp ./magefiles/mage ./mage
|
|
|
|
# Install Flamenco generators
|
|
RUN ./mage installGenerators || go run mage.go installDeps
|
|
|
|
# =============================================================================
|
|
# Development stage - Full development environment
|
|
# =============================================================================
|
|
FROM build-tools AS development
|
|
|
|
# Install development tools (compatible with Go 1.24)
|
|
RUN go install github.com/air-verse/air@v1.52.3
|
|
RUN go install github.com/githubnemo/CompileDaemon@latest
|
|
|
|
# Copy mage binary from build-tools stage
|
|
COPY --from=build-tools /app/mage ./mage
|
|
|
|
# Copy full source code
|
|
COPY . .
|
|
|
|
# Generate code
|
|
RUN ./mage generate || make generate
|
|
|
|
# Build static assets for embedding
|
|
RUN ./mage webappStatic || make webapp-static
|
|
|
|
# Build Flamenco binaries for development
|
|
RUN ./mage build
|
|
|
|
# Copy binaries to /usr/local/bin to avoid mount override
|
|
RUN cp flamenco-manager /usr/local/bin/ && cp flamenco-worker /usr/local/bin/ && cp mage /usr/local/bin/
|
|
|
|
# Expose ports
|
|
EXPOSE 8080 8081 8082
|
|
|
|
# Development command with hot-reloading
|
|
CMD ["./mage", "devServer"]
|
|
|
|
# =============================================================================
|
|
# Builder stage - Build production binaries
|
|
# =============================================================================
|
|
FROM build-tools AS builder
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Generate all code
|
|
RUN ./mage generate
|
|
|
|
# Build webapp static files
|
|
RUN ./mage webappStatic
|
|
|
|
# Build Flamenco binaries
|
|
RUN ./mage build
|
|
|
|
# Verify binaries exist
|
|
RUN ls -la flamenco-manager flamenco-worker
|
|
|
|
# =============================================================================
|
|
# Production stage - Minimal runtime image
|
|
# =============================================================================
|
|
FROM alpine:latest AS production
|
|
|
|
# Install runtime dependencies
|
|
RUN apk add --no-cache \
|
|
ca-certificates \
|
|
sqlite \
|
|
tzdata
|
|
|
|
# Create flamenco user
|
|
RUN addgroup -g 1000 flamenco && \
|
|
adduser -D -s /bin/sh -u 1000 -G flamenco flamenco
|
|
|
|
# Create directories
|
|
RUN mkdir -p /app /data /shared-storage && \
|
|
chown -R flamenco:flamenco /app /data /shared-storage
|
|
|
|
# Copy binaries from builder
|
|
COPY --from=builder /app/flamenco-manager /app/flamenco-worker /app/
|
|
COPY --from=builder /app/web/static /app/web/static
|
|
|
|
# Set ownership
|
|
RUN chown -R flamenco:flamenco /app
|
|
|
|
USER flamenco
|
|
WORKDIR /app
|
|
|
|
# Default to manager, can be overridden
|
|
CMD ["./flamenco-manager"]
|
|
|
|
# =============================================================================
|
|
# Test stage - For running tests in CI
|
|
# =============================================================================
|
|
FROM build-tools AS test
|
|
|
|
COPY . .
|
|
RUN ./mage generate
|
|
RUN ./mage check
|
|
|
|
# =============================================================================
|
|
# Tools stage - Development utilities
|
|
# =============================================================================
|
|
FROM base AS tools
|
|
|
|
# Install additional development tools
|
|
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
RUN go install github.com/pressly/goose/v3/cmd/goose@latest
|
|
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
|
|
|
CMD ["/bin/bash"] |