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
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@ ENV PYTHONUNBUFFERED=1
# Document the port number the container will expose
EXPOSE 8000

# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
# Copy startup script
COPY scripts/startup.sh /app/
RUN chmod +x /app/startup.sh

# Run the startup script
CMD ["/app/startup.sh"]
13 changes: 13 additions & 0 deletions scripts/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

# Create runtime config with environment variables
mkdir -p /app/frontend/dist/assets
cat > /app/frontend/dist/assets/runtime-config.js <<EOL
window.RUNTIME_CONFIG = {
CODER_URL: "${CODER_URL}"
};
EOL

# Start the application
exec uvicorn main:app --host 0.0.0.0 --port 8000
1 change: 1 addition & 0 deletions src/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<title>Pad.ws</title>
<link rel="icon" type="image/x-icon" href="/assets/images/favicon.png" />
<script src="/assets/runtime-config.js"></script>
</head>

<body>
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/AuthGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default function AuthGate({ children }: { children: React.ReactNode }) {
if (isAuthenticated === true && !coderAuthDone) {
const iframe = document.createElement("iframe");
iframe.style.display = "none";
const coderUrl = import.meta.env.CODER_URL;
// Use runtime config if available, fall back to import.meta.env
const coderUrl = window.RUNTIME_CONFIG?.CODER_URL || import.meta.env.CODER_URL;
iframe.src = `${coderUrl}/api/v2/users/oidc/callback`;
console.debug(`[pad.ws] (Silently) Priming Coder OIDC session for ${coderUrl}`);

Expand Down
6 changes: 6 additions & 0 deletions src/frontend/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface Window {
RUNTIME_CONFIG?: {
CODER_URL: string;
};
ExcalidrawLib: any;
}