Skip to content

Modern Docker Management, Designed for Everyone

2.0 KB
Raw Blame
# syntax=docker/dockerfile:1

# Stage 1: Frontend Development with optimized caching
FROM --platform=$BUILDPLATFORM ghcr.io/voidzero-dev/vite-plus:latest AS frontend-dev

ENV CI=true

WORKDIR /app

# Copy dependency manifests first to preserve the install layer cache
COPY --chown=vp:vp --parents pnpm-lock.yaml pnpm-workspace.yaml package.json \
    frontend/package.json tests/package.json ./

# Install dependencies with a persistent package store cache
RUN mkdir -p /home/vp/.local/share/pnpm/store
RUN --mount=type=cache,id=arcane-pnpm-v3,target=/home/vp/.local/share/pnpm/store,sharing=locked,uid=1000,gid=1000 \
    vp install --frozen-lockfile --prefer-offline --filter ./frontend...

# Copy frontend source
COPY --chown=vp:vp frontend ./frontend

ENV NODE_ENV=development \
    PORT=3000

EXPOSE 3000

CMD ["vp", "-C", "frontend", "run", "dev"]

# Stage 2: Backend Development with optimized caching
FROM --platform=$BUILDPLATFORM golang:1.27-trixie AS backend-dev

# Install development tools in a single layer
RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    git \
    tzdata && \
    rm -rf /var/lib/apt/lists/* && \
    go install github.com/air-verse/air@latest

ENV GIN_MODE=debug \
    PORT=3552 \
    ENVIRONMENT=development \
    ARCANE_IN_CONTAINER=true \
    GOCACHE=/root/.cache/go-build \
    GOMODCACHE=/go/pkg/mod

WORKDIR /app

# Copy Go workspace file and all modules first
COPY go.work ./go.work
COPY types/ ./types/
COPY cli/ ./cli/

# Copy backend Go module files for dependency caching
COPY backend/go.mod backend/go.sum ./backend/

# Download dependencies with cache mounts
RUN --mount=type=cache,target=/go/pkg/mod \
    --mount=type=cache,target=/root/.cache/go-build \
    cd backend && go mod download && go mod verify

# Create directories with proper permissions
RUN mkdir -p /app/data /app/.bin /builds && \
    chmod 755 /app/data /app/.bin

WORKDIR /app/backend

EXPOSE 3552

CMD ["air", "-c", ".air.toml"]