Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ jobs:
echo " ghcr.io/${REPO_LOWER}-backend:latest" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Run frontend" >> $GITHUB_STEP_SUMMARY
echo "docker run -d -p 80:80 \\" >> $GITHUB_STEP_SUMMARY
echo "docker run -d -p 3000:3000 \\" >> $GITHUB_STEP_SUMMARY
echo " --name csf-frontend \\" >> $GITHUB_STEP_SUMMARY
echo " ghcr.io/${REPO_LOWER}-frontend:latest" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
Expand Down
10 changes: 6 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ RUN cargo chef cook --release --recipe-path recipe.json
COPY src ./src
COPY migration/src ./migration/src
COPY entity/src ./entity/src
# Fix: Update timestamps to force rebuild, otherwise cargo might skip building if host files are older than dummy files
RUN touch src/main.rs migration/src/lib.rs entity/src/lib.rs
RUN cargo build --release

###################
Expand All @@ -64,6 +66,7 @@ RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
sqlite3 \
curl \
&& rm -rf /var/lib/apt/lists/*

# Create data directory for SQLite
Expand All @@ -72,17 +75,16 @@ RUN mkdir -p /data
# Copy backend binary from builder
COPY --from=backend-builder /usr/src/app/target/release/backend /app/backend

# Expose backend port (frontend proxy is handled by backend)
# Expose backend port
EXPOSE 8000

# Set environment variables
ENV DATABASE_URL=sqlite:/data/finance.db
ENV RUST_LOG=info
ENV FRONTEND_URL=http://localhost:3000

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD ["/app/backend", "--health-check"] || exit 1
CMD curl -f http://localhost:8000/api/system/health || exit 1

# Start backend (it will proxy to frontend)
# Start backend
CMD ["./backend"]
5 changes: 1 addition & 4 deletions backend/src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use tracing::{info_span, Span};

pub mod agents;
pub mod expenses;
pub mod frontend;
pub mod marketplace;
pub mod organizations;
pub mod resource_groups;
Expand Down Expand Up @@ -67,7 +66,7 @@ pub fn create_router() -> Router<AppState> {
.merge(users::users_routes());

Router::new()
// API routes have priority
// API routes
.logged_nest("/api", api_router)
.layer(
TraceLayer::new_for_http()
Expand All @@ -92,6 +91,4 @@ pub fn create_router() -> Router<AppState> {
),
)
.layer(cors)
// Frontend proxy as fallback - catches all routes not handled above
.fallback_service(frontend::frontend_router())
}
11 changes: 11 additions & 0 deletions backend/src/routes/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,21 @@ pub struct SystemMetricsResponse {

pub fn routes() -> Router<AppState> {
Router::new()
.route("/system/health", get(health_check))
.route("/system/info", get(get_system_info))
.route("/system/metrics", get(get_system_metrics))
}

/// Health check endpoint
///
/// Simple endpoint to check if the service is running
async fn health_check() -> Json<serde_json::Value> {
Json(serde_json::json!({
"status": "healthy",
"service": "csf-core-backend"
}))
}

/// Get local system information
///
/// Returns static system information like hostname, OS, CPU details
Expand Down
21 changes: 15 additions & 6 deletions frontend/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ RUN npm ci

COPY . .

# Set production environment variable for build
ENV PUBLIC_API_BASE_URL=/api
# Setenv variables during build if necessary
ENV PUBLIC_API_BASE_URL=http://localhost:8000

RUN npm run build

FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# Runtime Stage
FROM node:20-alpine

WORKDIR /app

COPY --from=build /app/build ./build
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/node_modules ./node_modules

EXPOSE 3000

ENV PORT=3000
CMD ["node", "build/index.js"]
Loading