Refactor Docker setup and enhance backend configuration #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| DATABASE_URL: postgres://postgres:dev@localhost:5432/e2ee | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build Postgres image | |
| run: docker build -t postgres-ee -f Dockerfile . | |
| - name: Start Postgres container | |
| run: | | |
| docker run -d --name postgres-ee \ | |
| -p 5432:5432 \ | |
| -e POSTGRES_USER=postgres \ | |
| -e POSTGRES_PASSWORD=dev \ | |
| -e POSTGRES_DB=e2ee \ | |
| postgres | |
| until docker exec postgres-ee pg_isready -U postgres > /dev/null 2>&1; do | |
| echo "Waiting for Postgres to be ready..." | |
| sleep 2 | |
| done | |
| echo "Postgres is ready." | |
| - name: Cache Cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry/index | |
| ~/.cargo/registry/cache | |
| ~/.cargo/git/db | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build | |
| run: cargo build --verbose | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Stop Postgres container | |
| if: always() | |
| run: docker rm -f postgres-ee | |
| - name: Format code | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| cargo fmt | |
| git diff --exit-code || { git config user.name "GitHub Actions"; git config user.email "actions@github.com"; git add .; git commit -m "Auto-fix ESLint issues"; git push origin $GITHUB_REF; } | |