fix: pass RAILWAY_GIT_COMMIT_SHA through Docker, provide Cargo.toml for frontend (version retrieval)

This commit is contained in:
2025-09-13 22:02:41 -05:00
parent 176574343f
commit e370008d75
2 changed files with 13 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
# Build arguments # Build arguments
ARG RUST_VERSION=1.89.0 ARG RUST_VERSION=1.89.0
ARG RAILWAY_GIT_COMMIT_SHA
# Frontend Build Stage # Frontend Build Stage
FROM node:22-bookworm-slim AS frontend-builder FROM node:22-bookworm-slim AS frontend-builder
@@ -9,6 +10,9 @@ RUN npm install -g pnpm
WORKDIR /app WORKDIR /app
# Copy backend Cargo.toml for build-time version retrieval
COPY ./Cargo.toml ./
# Copy frontend package files # Copy frontend package files
COPY ./web/package.json ./web/pnpm-lock.yaml ./ COPY ./web/package.json ./web/pnpm-lock.yaml ./
@@ -24,6 +28,9 @@ RUN pnpm run build
# Rust Build Stage # Rust Build Stage
FROM rust:${RUST_VERSION}-bookworm AS builder FROM rust:${RUST_VERSION}-bookworm AS builder
# Set build-time environment variable for Railway Git commit SHA
ENV RAILWAY_GIT_COMMIT_SHA=${RAILWAY_GIT_COMMIT_SHA}
# Install build dependencies # Install build dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
pkg-config \ pkg-config \

View File

@@ -18,13 +18,9 @@ import TimeAgo from "react-timeago";
import { ThemeToggle } from "../components/ThemeToggle"; import { ThemeToggle } from "../components/ThemeToggle";
import "../App.css"; import "../App.css";
export const Route = createFileRoute("/")({
component: App,
});
// Constants
const REFRESH_INTERVAL = import.meta.env.DEV ? 3000 : 30000; const REFRESH_INTERVAL = import.meta.env.DEV ? 3000 : 30000;
const REQUEST_TIMEOUT = 10000; // 10 seconds const REQUEST_TIMEOUT = 10000; // 10 seconds
const CARD_STYLES = { const CARD_STYLES = {
padding: "24px", padding: "24px",
maxWidth: "400px", maxWidth: "400px",
@@ -37,14 +33,12 @@ const BORDER_STYLES = {
borderTop: "1px solid var(--gray-7)", borderTop: "1px solid var(--gray-7)",
} as const; } as const;
// Service icon mapping
const SERVICE_ICONS: Record<string, typeof Bot> = { const SERVICE_ICONS: Record<string, typeof Bot> = {
bot: Bot, bot: Bot,
banner: Globe, banner: Globe,
discord: MessageCircle, discord: MessageCircle,
}; };
// Types
interface ResponseTiming { interface ResponseTiming {
health: number | null; health: number | null;
status: number | null; status: number | null;
@@ -80,7 +74,6 @@ type StatusState =
lastFetch: Date; lastFetch: Date;
}; };
// Helper functions
const formatNumber = (num: number): string => { const formatNumber = (num: number): string => {
return num.toLocaleString(); return num.toLocaleString();
}; };
@@ -117,7 +110,6 @@ const getServices = (state: StatusState): Service[] => {
); );
}; };
// Status Component
const StatusDisplay = ({ status }: { status: Status | "Unreachable" }) => { const StatusDisplay = ({ status }: { status: Status | "Unreachable" }) => {
const { icon: Icon, color } = getStatusIcon(status); const { icon: Icon, color } = getStatusIcon(status);
@@ -137,7 +129,6 @@ const StatusDisplay = ({ status }: { status: Status | "Unreachable" }) => {
); );
}; };
// Service Status Component
const ServiceStatus = ({ service }: { service: Service }) => { const ServiceStatus = ({ service }: { service: Service }) => {
return ( return (
<Flex align="center" justify="between"> <Flex align="center" justify="between">
@@ -150,7 +141,6 @@ const ServiceStatus = ({ service }: { service: Service }) => {
); );
}; };
// Skeleton Service Component
const SkeletonService = () => { const SkeletonService = () => {
return ( return (
<Flex align="center" justify="between"> <Flex align="center" justify="between">
@@ -166,7 +156,6 @@ const SkeletonService = () => {
); );
}; };
// Timing Row Component
const TimingRow = ({ const TimingRow = ({
icon: Icon, icon: Icon,
name, name,
@@ -190,7 +179,7 @@ const TimingRow = ({
function App() { function App() {
const [state, setState] = useState<StatusState>({ mode: "loading" }); const [state, setState] = useState<StatusState>({ mode: "loading" });
// Helper variables for state checking // State helpers
const isLoading = state.mode === "loading"; const isLoading = state.mode === "loading";
const hasError = state.mode === "error"; const hasError = state.mode === "error";
const hasTimeout = state.mode === "timeout"; const hasTimeout = state.mode === "timeout";
@@ -428,3 +417,7 @@ function App() {
</div> </div>
); );
} }
export const Route = createFileRoute("/")({
component: App,
});