Remove problematic caching systems

This commit is contained in:
Christbru 2025-10-18 19:03:11 -05:00
commit 151a354518
2 changed files with 12 additions and 27 deletions

View file

@ -4,7 +4,7 @@ name: Build and Deploy
on:
push:
branches: ["deploytest"]
branches: ["main", "deploytest"]
jobs:
build-and-deploy:
@ -19,7 +19,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
# --- NEW STEP TO FIX THE ERROR ---
- name: Set repo name to lowercase
id: repo_name
run: echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
@ -34,28 +33,20 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# --- Build and push one image for each service ---
- name: Build and push web-app image 🚀
uses: docker/build-push-action@v6
with:
context: ./web-app
push: true
# CHANGED: Uses the new lowercase repo name
tags: ghcr.io/${{ steps.repo_name.outputs.name }}/web-app:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push Rust engine image ⚙️
uses: docker/build-push-action@v6
with:
context: ./rust-engine
push: true
# CHANGED: Uses the new lowercase repo name
tags: ghcr.io/${{ steps.repo_name.outputs.name }}/rust-engine:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# --- Deploy the new images to your server ---
- name: Deploy to server via SSH ☁️
uses: appleboy/ssh-action@v1.0.3
with:

View file

@ -1,38 +1,32 @@
# rust-engine/Dockerfile
# --- Stage 1: Builder ---
# Use a stable Rust version
FROM rust:1.82-slim AS builder
WORKDIR /usr/src/app
# Install build dependencies
# Install build dependencies needed for sqlx
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy ONLY Cargo.toml
COPY Cargo.toml ./
# Copy the ENTIRE project at once. This ensures Cargo sees a valid project.
COPY . .
# --- KEY CHANGE: Create a dummy main.rs BEFORE fetching dependencies ---
RUN mkdir src && echo "fn main() {}" > src/main.rs
# Now, generate the lock file and fetch dependencies
RUN cargo update && cargo fetch
# Remove the dummy file before copying the real source code
RUN rm -rf src
# Now copy the rest of your source code
COPY src ./src
# Build the project using the pre-fetched dependencies
# Build the project. Cargo will resolve dependencies and compile.
RUN cargo build --release
# --- Stage 2: Final Image ---
# --- Stage 2: Final, small image ---
FROM debian:bookworm-slim
# Install only necessary runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Copy the compiled binary from the builder stage
COPY --from=builder /usr/src/app/target/release/rust-engine /usr/local/bin/rust-engine
EXPOSE 8000
CMD ["rust-engine"]