ci: optimize build + deploy + migrate workflows #51

Merged
rock merged 8 commits from ci/optimize-workflows into main 2026-09-13 05:42:04 +00:00
3 changed files with 84 additions and 14 deletions
Showing only changes of commit 346a615535 - Show all commits
+51 -8
View File
@@ -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
+20 -2
View File
@@ -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
View File
@@ -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