diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..687cb37 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,57 @@ +name: Build & Deploy NutriApp +on: + push: + branches: [main] + +jobs: + build-and-deploy: + runs-on: rust-builder + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Install Docker CLI + run: | + apt-get update -qq && apt-get install -y -qq ca-certificates curl + curl -fsSL https://download.docker.com/linux/static/stable/aarch64/docker-27.3.1.tgz | tar xz + cp docker/docker /usr/local/bin/ + docker version + + - name: Cache Cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Install wasm-pack + dioxus-cli + run: | + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + cargo install dioxus-cli --version 0.6.3 2>/dev/null || echo "dioxus-cli already installed" + + - name: Build Backend (Rust) + run: cargo build --release -p nutriapp-backend + + - name: Build Frontend (Dioxus → WASM) + run: | + cd frontend + dx build --release + + - name: Build & Push Docker image + env: + REGISTRY: k3s.proyectosjoel.com + IMAGE_TAG: ${{ gitea.sha }} + run: | + docker build -t $REGISTRY/nutriapp:$IMAGE_TAG -t $REGISTRY/nutriapp:latest -f Dockerfile . + docker push $REGISTRY/nutriapp:$IMAGE_TAG + docker push $REGISTRY/nutriapp:latest + + - name: Deploy to k3s + run: | + kubectl apply -f k8s/deployment.yml -n nutriapp + kubectl rollout status deployment/nutriapp -n nutriapp --timeout=120s + kubectl get pods -n nutriapp