fix: docker build out-of-disk issue - aggressive cleanup
CI / CI (pull_request) Successful in 11m39s
CI / CI (pull_request) Successful in 11m39s
- .dockerignore: exclude build/cache/docs to reduce build context (59 lines) - Dockerfile: add aggressive cleanup (cache, registry, git) after cargo build - Dockerfile: use --locked flag for reproducible builds - build.yaml: add pre-build disk cleanup (docker + cargo cache) - build.yaml: clean cargo before Docker build to free space - build.yaml: show disk usage before/after for debugging Fixes 'No space left on device' error during Docker build in runner
This commit is contained in:
+51
-8
@@ -1,12 +1,55 @@
|
|||||||
|
# Git
|
||||||
.git
|
.git
|
||||||
.gitignore
|
.gitignore
|
||||||
|
.gitattributes
|
||||||
|
|
||||||
|
# CI/CD
|
||||||
|
.github
|
||||||
|
.gitea
|
||||||
|
.gitlab-ci.yml
|
||||||
|
|
||||||
|
# Kubernetes
|
||||||
|
k8s/
|
||||||
|
helm/
|
||||||
|
|
||||||
|
# Documentation
|
||||||
*.md
|
*.md
|
||||||
__pycache__
|
docs/
|
||||||
*.pyc
|
|
||||||
.env.local
|
# IDE
|
||||||
.venv
|
.vscode
|
||||||
venv/
|
.idea
|
||||||
.pytest_cache
|
*.swp
|
||||||
.coverage
|
*.swo
|
||||||
htmlcov
|
*~
|
||||||
|
|
||||||
|
# OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Build artifacts
|
||||||
|
target/
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Dependencies (will be downloaded fresh)
|
||||||
|
.cargo/
|
||||||
|
Cargo.lock.bak
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
.coverage
|
||||||
|
coverage/
|
||||||
|
|
||||||
|
# Secrets
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# Archives
|
||||||
|
*.tar
|
||||||
|
*.tar.gz
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
# Node (if any)
|
||||||
|
node_modules/
|
||||||
|
*.log
|
||||||
|
|||||||
@@ -18,6 +18,15 @@ jobs:
|
|||||||
name: CI
|
name: CI
|
||||||
runs-on: rust
|
runs-on: rust
|
||||||
steps:
|
steps:
|
||||||
|
- name: Clean disk space (runner GC)
|
||||||
|
run: |
|
||||||
|
df -h /
|
||||||
|
echo "Cleaning docker, cargo cache..."
|
||||||
|
docker system prune -af --volumes || true
|
||||||
|
rm -rf ~/.cargo/registry/cache ~/.cargo/registry/index ~/.cargo/git || true
|
||||||
|
rm -rf /tmp/* || true
|
||||||
|
df -h /
|
||||||
|
|
||||||
- name: Install Node.js and Docker
|
- name: Install Node.js and Docker
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
apt-get update
|
||||||
@@ -48,6 +57,12 @@ jobs:
|
|||||||
REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }}
|
REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }}
|
||||||
REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }}
|
REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Clean cargo before Docker build
|
||||||
|
run: |
|
||||||
|
cargo clean || true
|
||||||
|
rm -rf ~/.cargo/registry/cache ~/.cargo/registry/index ~/.cargo/git || true
|
||||||
|
df -h /
|
||||||
|
|
||||||
- name: Build and push Docker image (SHA tag only)
|
- name: Build and push Docker image (SHA tag only)
|
||||||
run: |
|
run: |
|
||||||
docker build --no-cache --progress=plain \
|
docker build --no-cache --progress=plain \
|
||||||
@@ -56,5 +71,8 @@ jobs:
|
|||||||
docker push "${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
docker push "${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
||||||
echo "Pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
echo "Pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
||||||
|
|
||||||
- name: Prune unused images
|
- name: Prune unused images and cleanup
|
||||||
run: docker image prune -a --force 2>&1 | tail -3 || true
|
run: |
|
||||||
|
docker image prune -a --force 2>&1 | tail -3 || true
|
||||||
|
cargo clean || true
|
||||||
|
df -h /
|
||||||
|
|||||||
+13
-4
@@ -5,14 +5,23 @@ FROM rust:1-bookworm as builder
|
|||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
|
# Build settings
|
||||||
|
ENV SQLX_OFFLINE=true
|
||||||
|
|
||||||
# Copy source
|
# Copy source
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the mem binary (offline sqlx - uses .sqlx/ cache)
|
# Build release binary with space-efficient cleanup
|
||||||
ENV SQLX_OFFLINE=true
|
RUN cargo build --release -p mem-cli --locked && \
|
||||||
RUN cargo build --release -p mem-cli && \
|
|
||||||
strip target/release/mem && \
|
strip target/release/mem && \
|
||||||
rm -rf target/release/deps target/release/build target/release/incremental target/release/.fingerprint
|
# Aggressive cleanup to free disk space
|
||||||
|
rm -rf target/release/deps && \
|
||||||
|
rm -rf target/release/build && \
|
||||||
|
rm -rf target/release/incremental && \
|
||||||
|
rm -rf target/release/.fingerprint && \
|
||||||
|
rm -rf .cargo/registry/cache && \
|
||||||
|
rm -rf .cargo/registry/index && \
|
||||||
|
rm -rf .cargo/git
|
||||||
|
|
||||||
# Stage 2: Runtime
|
# Stage 2: Runtime
|
||||||
FROM debian:bookworm-slim
|
FROM debian:bookworm-slim
|
||||||
|
|||||||
Reference in New Issue
Block a user