BLOG-59 Enhance deployment workflow and backend server configuration (#60)
All checks were successful
Frontend CI / build (push) Successful in 1m37s

### Description

- Updated deployment.yaml to specify separate build and push steps for frontend and backend.
- Added Dockerfile for backend service to define build process.
- Modified main.rs to bind the server to all network interfaces (0.0.0.0) instead of localhost.

### Package Changes

_No response_

### Screenshots

_No response_

### Reference

Resolves #59

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #60
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
This commit is contained in:
SquidSpirit 2025-07-23 00:59:18 +08:00 committed by squid
parent d74107a0f9
commit 0726b11fe2
3 changed files with 27 additions and 2 deletions

View File

@ -24,7 +24,7 @@ jobs:
username: ${{ vars.REGISTRY_USERNAME }} username: ${{ vars.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }} password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push - name: Build and push (Frontend)
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
push: true push: true
@ -33,3 +33,13 @@ jobs:
tags: | tags: |
${{ vars.REGISTRY }}/${{ vars.IMAGE_REPO_FRONTEND }}:latest ${{ vars.REGISTRY }}/${{ vars.IMAGE_REPO_FRONTEND }}:latest
${{ vars.REGISTRY }}/${{ vars.IMAGE_REPO_FRONTEND }}:${{ gitea.event.release.tag_name }} ${{ vars.REGISTRY }}/${{ vars.IMAGE_REPO_FRONTEND }}:${{ gitea.event.release.tag_name }}
- name: Build and push (Backend)
uses: docker/build-push-action@v6
with:
push: true
provenance: false
context: ./backend
tags: |
${{ vars.REGISTRY }}/${{ vars.IMAGE_REPO_BACKEND }}:latest
${{ vars.REGISTRY }}/${{ vars.IMAGE_REPO_BACKEND }}:${{ gitea.event.release.tag_name }}

15
backend/Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM rust:1-slim AS base
RUN apt update -qq && apt install -y -qq --no-install-recommends musl-tools
RUN rustup target add x86_64-unknown-linux-musl
FROM base AS builder
WORKDIR /app
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl
FROM alpine:latest AS runner
WORKDIR /app
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/server .
EXPOSE 8080
ENV DATABASE_URL=postgres://postgres@localhost:5432/postgres
CMD ["./server"]

View File

@ -17,7 +17,7 @@ async fn main() -> std::io::Result<()> {
let db_pool = init_database().await; let db_pool = init_database().await;
HttpServer::new(move || create_app(db_pool.clone())) HttpServer::new(move || create_app(db_pool.clone()))
.bind(("127.0.0.1", 8080))? .bind(("0.0.0.0", 8080))?
.run() .run()
.await .await
} }