chore(ci): add Docker BuildKit examples, .dockerignore, CI cache docs; tune vite config
This commit is contained in:
27
aether_container_env/Dockerfile.buildkit.example
Normal file
27
aether_container_env/Dockerfile.buildkit.example
Normal file
@@ -0,0 +1,27 @@
|
||||
## BuildKit-friendly multi-stage Dockerfile example for Aether frontend
|
||||
|
||||
# Stage 1: dependencies
|
||||
FROM node:20-alpine AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --no-audit --prefer-offline
|
||||
|
||||
# Stage 2: build
|
||||
FROM node:20-alpine AS build
|
||||
WORKDIR /app
|
||||
# optionally reuse deps from previous stage
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
# If you want to use BuildKit cache mounts during local development, uncomment the next line
|
||||
# RUN --mount=type=cache,target=/root/.npm npm ci
|
||||
RUN npm run build
|
||||
|
||||
# Stage 3: runtime (static site served by nginx)
|
||||
FROM nginx:stable-alpine AS runtime
|
||||
COPY --from=build /app/build /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
# Notes:
|
||||
# - Keep dependency installation separate from copying source to maximize cache hits when only application code changes.
|
||||
# - For backend images, follow the same pattern: install deps early, copy source later, and keep a small final runtime image.
|
||||
33
aether_container_env/ci_buildx_example.sh
Normal file
33
aether_container_env/ci_buildx_example.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Example CI script to build and push an image with buildx using registry cache.
|
||||
# This script is provider-agnostic and intended to be run inside CI where
|
||||
# Docker and buildx are available and authenticated against the registry.
|
||||
|
||||
REGISTRY=${REGISTRY:-ghcr.io/ORG/REPO}
|
||||
IMAGE_TAG=${IMAGE_TAG:-staging}
|
||||
CACHE_REF=${CACHE_REF:-${REGISTRY}:cache}
|
||||
|
||||
echo "Building ${REGISTRY}:${IMAGE_TAG} using registry cache ${CACHE_REF}"
|
||||
|
||||
docker buildx build \
|
||||
--push \
|
||||
--tag ${REGISTRY}:${IMAGE_TAG} \
|
||||
--cache-from type=registry,ref=${CACHE_REF} \
|
||||
--cache-to type=registry,ref=${CACHE_REF},mode=max \
|
||||
.
|
||||
|
||||
echo "Build complete. Image: ${REGISTRY}:${IMAGE_TAG}"
|
||||
|
||||
# Optional: instruct devs how to run locally with a local cache
|
||||
cat <<'EOF'
|
||||
Local test with BuildKit and local cache:
|
||||
DOCKER_BUILDKIT=1 docker build \
|
||||
--tag myapp:staging \
|
||||
--cache-to=type=local,dest=/tmp/docker-cache \
|
||||
--cache-from=type=local,src=/tmp/docker-cache .
|
||||
|
||||
Prune local builder cache older than 72 hours:
|
||||
docker builder prune --filter "until=72h" --force
|
||||
EOF
|
||||
Reference in New Issue
Block a user