This commit is contained in:
Ishaan Dey 2024-05-24 01:28:50 -07:00
parent 30e1c39d6c
commit 2abc9d4a4c
4 changed files with 19 additions and 14 deletions

View File

@ -2,8 +2,8 @@ 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
RUN apt-get update && apt-get install -y libcap2-bin && \
setcap cap_net_bind_service=+ep /usr/local/bin/node
WORKDIR /code
@ -15,14 +15,19 @@ 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
RUN useradd -m sboxuser
RUN mkdir projects && chown -R sboxuser:sboxuser projects
# user namespace mapping
# todo user namespace mapping
EXPOSE 3000
RUN apt-get install -y firejail
RUN echo '#!/bin/bash\nexec firejail --private=/projects --noprofile node dist/index.js' > /start.sh
RUN chmod +x /start.sh
USER sboxuser
EXPOSE 8000
EXPOSE 4000
CMD [ "node", "dist/index.js" ]
CMD ["/start.sh"]

View File

@ -342,8 +342,8 @@ io.on("connection", async (socket) => {
const onExit = pty.onExit((code) => console.log("exit :(", code));
pty.write("export PS1='\\u > '\r");
pty.write("clear\r");
pty.write("export PS1='> '\r");
terminals[id] = {
terminal: pty,

View File

@ -56,7 +56,7 @@ import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
port: 8000,
},
})
`,

View File

@ -34,7 +34,7 @@ export default function PreviewWindow({
<div className="text-xs">
Preview
<span className="inline-block ml-2 items-center font-mono text-muted-foreground">
localhost:3000
localhost:8000
</span>
</div>
<div className="flex space-x-1 translate-x-1">
@ -51,7 +51,7 @@ export default function PreviewWindow({
<PreviewButton
onClick={() => {
navigator.clipboard.writeText(`http://${ip}:3000`);
navigator.clipboard.writeText(`http://${ip}:8000`);
toast.info("Copied preview link to clipboard");
}}
>
@ -77,7 +77,7 @@ export default function PreviewWindow({
ref={ref}
width={"100%"}
height={"100%"}
src={`http://${ip}:3000`}
src={`http://${ip}:8000`}
/>
</div>
)}