Skip to content

Deployment Guide

Semua backend services di-deploy ke Fly.io (region Singapore). Frontend clients di-deploy ke Vercel. Setiap service punya Dockerfile multi-stage sendiri dan di-build via GitHub Actions.

Terminal window
# Install flyctl
brew install flyctl
# Login
flyctl auth login

Contoh untuk auth-api:

Terminal window
cd waqfuel-auth-api
# Launch app (pertama kali)
flyctl launch --no-deploy --name waqfuel-auth-api-prod --region sin
# Set secrets (env vars sensitif)
flyctl secrets set \
DATABASE_URL="postgresql://..." \
JWT_PRIVATE_KEY="$(cat keys/private.pem)" \
JWT_PUBLIC_KEY="$(cat keys/public.pem)" \
JWT_KEY_ID="key-prod-001" \
SUPER_ADMIN_EMAIL="admin@waqfuel.com" \
SUPER_ADMIN_PASSWORD="..." \
RESEND_API_KEY="re_..." \
GRPC_REFERENCE="waqfuel-reference-api-prod.internal:50050" \
GRPC_NOTIF="waqfuel-notif-api-prod.internal:50052"
# Deploy
flyctl deploy

Semua services menggunakan multi-stage Docker build yang serupa:

# Stage 1: Build dependencies (cached)
FROM rust:1.80-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y protobuf-compiler pkg-config libssl-dev
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release
RUN rm -f target/release/deps/service_name*
# Stage 2: Build app
COPY . .
RUN cargo build --release
# Stage 3: Runtime
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/service_name /usr/local/bin/
EXPOSE 8080 50051
CMD ["service_name"]

Services berkomunikasi via Fly private networking. Setiap app bisa diakses oleh app lain di organisasi yang sama via DNS internal:

<app-name>.internal:<port>

Contoh konfigurasi gRPC endpoints di production:

CallerTargetAddress
auth-apireference-api gRPCwaqfuel-reference-api-prod.internal:50050
auth-apinotif-api gRPCwaqfuel-notif-api-prod.internal:50052
main-apiauth-api gRPCwaqfuel-auth-api-prod.internal:50051
main-apiauth-api JWKShttps://auth.waqfuel.com/.well-known/jwks.json
app = "waqfuel-auth-api-prod"
primary_region = "sin"
[build]
dockerfile = "Dockerfile"
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = "stop"
auto_start_machines = true
min_machines_running = 0
[services]
protocol = "tcp"
internal_port = 50051
[[vm]]
size = "shared-cpu-1x"
memory = "512mb"
Terminal window
cd waqfuel-platform-client
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment variables di Vercel dashboard:

NEXT_PUBLIC_AUTH_API_URL=https://auth.waqfuel.com
NEXT_PUBLIC_MAIN_API_URL=https://api.waqfuel.com
NEXT_PUBLIC_REFERENCE_API_URL=https://ref.waqfuel.com
Terminal window
cd waqfuel-web
vercel --prod

Migrations dijalankan sebelum deploy (bukan di container startup). Jalankan dari local machine atau CI:

Terminal window
# Install sqlx-cli
cargo install sqlx-cli --features postgres
# Auth API migrations
cd waqfuel-auth-api
DATABASE_URL="postgresql://..." sqlx migrate run
# Main API migrations
cd waqfuel-main-api
DATABASE_URL="postgresql://..." sqlx migrate run
Terminal window
# Auth API
curl https://auth.waqfuel.com/health
# Main API — response includes DB + gRPC status
curl https://api.waqfuel.com/health
Terminal window
flyctl logs --app waqfuel-auth-api-prod
flyctl logs --app waqfuel-main-api-prod
Terminal window
flyctl status --app waqfuel-auth-api-prod
flyctl machine status --app waqfuel-auth-api-prod