improve orchestrator, docker settings, and ui layouts
This commit is contained in:
@ -1,2 +1,3 @@
|
||||
.env
|
||||
node_modules
|
||||
projects
|
@ -1,8 +1,10 @@
|
||||
ARG CF_API_TOKEN
|
||||
ARG CF_USER_ID
|
||||
|
||||
FROM node:20
|
||||
|
||||
# Security: Drop all capabilities
|
||||
USER root
|
||||
RUN apt-get update && apt-get install -y libcap2-bin
|
||||
RUN setcap cap_net_bind_service=+ep /usr/local/bin/node
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
COPY package*.json ./
|
||||
@ -13,8 +15,15 @@ COPY . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# Security: Create non-root user and assign ownership
|
||||
RUN useradd -m myuser
|
||||
RUN mkdir projects && chown -R myuser:myuser projects
|
||||
USER myuser
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ARG CF_API_TOKEN
|
||||
ARG CF_USER_ID
|
||||
ENV CF_API_TOKEN=$CF_API_TOKEN
|
||||
ENV CF_USER_ID=$CF_USER_ID
|
||||
|
||||
|
@ -435,15 +435,16 @@ io.on("connection", async (socket) => {
|
||||
clearTimeout(inactivityTimeout)
|
||||
};
|
||||
if (sockets.length === 0) {
|
||||
console.log("STARTING TIMER")
|
||||
inactivityTimeout = setTimeout(() => {
|
||||
io.fetchSockets().then(sockets => {
|
||||
io.fetchSockets().then(async (sockets) => {
|
||||
if (sockets.length === 0) {
|
||||
// close server
|
||||
console.log("Closing server due to inactivity.");
|
||||
stopServer(data.sandboxId, data.userId)
|
||||
// const res = await stopServer(data.sandboxId, data.userId)
|
||||
}
|
||||
});
|
||||
}, 60000);
|
||||
}, 20000);
|
||||
}
|
||||
|
||||
})
|
||||
|
@ -198,7 +198,7 @@ ${code}`,
|
||||
}
|
||||
|
||||
export const stopServer = async (sandboxId: string, userId: string) => {
|
||||
await fetch("http://localhost:4001/stop", {
|
||||
const res = await fetch("http://localhost:4001/stop", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@ -208,4 +208,7 @@ export const stopServer = async (sandboxId: string, userId: string) => {
|
||||
userId
|
||||
}),
|
||||
})
|
||||
const data = await res.json()
|
||||
|
||||
return data
|
||||
}
|
Reference in New Issue
Block a user