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
|
||||
.gitignore
|
||||
.gitattributes
|
||||
|
||||
# CI/CD
|
||||
.github
|
||||
.gitea
|
||||
.gitlab-ci.yml
|
||||
|
||||
# Kubernetes
|
||||
k8s/
|
||||
helm/
|
||||
|
||||
# Documentation
|
||||
*.md
|
||||
__pycache__
|
||||
*.pyc
|
||||
.env.local
|
||||
.venv
|
||||
venv/
|
||||
.pytest_cache
|
||||
.coverage
|
||||
htmlcov
|
||||
docs/
|
||||
|
||||
# IDE
|
||||
.vscode
|
||||
.idea
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS
|
||||
.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
|
||||
runs-on: rust
|
||||
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
|
||||
run: |
|
||||
apt-get update
|
||||
@@ -48,6 +57,12 @@ jobs:
|
||||
REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }}
|
||||
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)
|
||||
run: |
|
||||
docker build --no-cache --progress=plain \
|
||||
@@ -56,5 +71,8 @@ jobs:
|
||||
docker push "${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
||||
echo "Pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
||||
|
||||
- name: Prune unused images
|
||||
run: docker image prune -a --force 2>&1 | tail -3 || true
|
||||
- name: Prune unused images and cleanup
|
||||
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
|
||||
|
||||
# Build settings
|
||||
ENV SQLX_OFFLINE=true
|
||||
|
||||
# Copy source
|
||||
COPY . .
|
||||
|
||||
# Build the mem binary (offline sqlx - uses .sqlx/ cache)
|
||||
ENV SQLX_OFFLINE=true
|
||||
RUN cargo build --release -p mem-cli && \
|
||||
# Build release binary with space-efficient cleanup
|
||||
RUN cargo build --release -p mem-cli --locked && \
|
||||
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
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
Reference in New Issue
Block a user