Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
b97819ece9 |
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Use an official Nginx runtime as a parent image
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Set the working directory to the Nginx web root
|
||||||
|
WORKDIR /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Remove the default Nginx welcome page
|
||||||
|
RUN rm -f /usr/share/nginx/html/index.html
|
||||||
|
|
||||||
|
# Copy the static assets from the frontend directory into the container
|
||||||
|
# This includes your HTML, CSS, JS, and assets folders.
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Copy the custom Nginx configuration
|
||||||
|
# This replaces the default config with our version that includes the API proxy.
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# Expose port 80 to allow traffic to the Nginx server
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# The command to start Nginx when the container launches
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
@ -11,7 +11,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
const password = document.getElementById('password').value;
|
const password = document.getElementById('password').value;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('http://localhost:5000/api/login', {
|
const response = await fetch('/api/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ username, password }),
|
body: JSON.stringify({ username, password }),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
// --- CONFIGURATION ---
|
// --- CONFIGURATION ---
|
||||||
const SOCKET_URL = "http://localhost:5000";
|
const API_BASE = "/api"; // Added for API calls
|
||||||
const API_BASE = "http://localhost:5000/api"; // Added for API calls
|
|
||||||
|
|
||||||
// --- DOM ELEMENT REFERENCES ---
|
// --- DOM ELEMENT REFERENCES ---
|
||||||
const grid = document.getElementById('chambersGrid');
|
const grid = document.getElementById('chambersGrid');
|
||||||
|
|
@ -558,7 +557,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const connectSocket = () => {
|
const connectSocket = () => {
|
||||||
socket = io(SOCKET_URL);
|
socket = io();
|
||||||
|
|
||||||
// --- CHANGED: No longer sets status to "Online" on its own ---
|
// --- CHANGED: No longer sets status to "Online" on its own ---
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
// --- CONFIGURATION ---
|
// --- CONFIGURATION ---
|
||||||
const SOCKET_URL = "http://localhost:5000";
|
const API_BASE = "/api";
|
||||||
const API_BASE = "http://localhost:5000/api";
|
|
||||||
|
|
||||||
// --- DOM ELEMENT REFERENCES ---
|
// --- DOM ELEMENT REFERENCES ---
|
||||||
const stationNameEl = document.getElementById('station-name');
|
const stationNameEl = document.getElementById('station-name');
|
||||||
|
|
@ -76,7 +75,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- SOCKET.IO CONNECTION ---
|
// --- SOCKET.IO CONNECTION ---
|
||||||
socket = io(SOCKET_URL);
|
socket = io();
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
console.log("Connected to WebSocket for logs.");
|
console.log("Connected to WebSocket for logs.");
|
||||||
socket.emit('join_station_room', { station_id: selectedStation.id });
|
socket.emit('join_station_room', { station_id: selectedStation.id });
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
// --- DATA FETCHING & STATUS POLLING ---
|
// --- DATA FETCHING & STATUS POLLING ---
|
||||||
const loadAndPollStations = async () => {
|
const loadAndPollStations = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('http://localhost:5000/api/stations');
|
const response = await fetch('/api/stations');
|
||||||
if (!response.ok) throw new Error('Failed to fetch stations');
|
if (!response.ok) throw new Error('Failed to fetch stations');
|
||||||
const stations = await response.json();
|
const stations = await response.json();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
# Root directory for static files
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Serve static assets directly
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Proxy API requests to the backend service
|
||||||
|
# In Dokploy, you would set 'backend' to the name of your backend service.
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://backend:5000/;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Proxy WebSocket connections to the backend service
|
||||||
|
location /socket.io/ {
|
||||||
|
proxy_pass http://backend:5000/socket.io/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue