Compare commits
1 Commits
feat/docke
...
feat/no-lo
Author | SHA1 | Date | |
---|---|---|---|
e58d088b5f |
@ -1,3 +0,0 @@
|
|||||||
frontend/node_modules
|
|
||||||
backend/server/.env
|
|
||||||
backend/server/node_modules
|
|
25
.github/workflows/docker-image.yml
vendored
25
.github/workflows/docker-image.yml
vendored
@ -1,25 +0,0 @@
|
|||||||
name: Docker Image CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "main" ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Write .env file
|
|
||||||
run: echo "${{secrets.FRONTEND_DOT_ENV}}" > ./frontend/.env
|
|
||||||
- name: Login Dockerhub
|
|
||||||
env:
|
|
||||||
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
|
|
||||||
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
|
|
||||||
run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
|
|
||||||
- name: Build the Docker image
|
|
||||||
run: docker build -t jamesmurdza/sandbox .
|
|
||||||
- name: Push to Dockerhub
|
|
||||||
run: docker push jamesmurdza/sandbox:latest
|
|
41
dockerfile
41
dockerfile
@ -1,41 +0,0 @@
|
|||||||
# docker build -t myimage .
|
|
||||||
# docker run --env-file backend/server/.env -p 3000:3000 -p 4000:4000 myimage
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Build backend
|
|
||||||
WORKDIR /backend
|
|
||||||
COPY backend/server/package*.json ./
|
|
||||||
RUN npm install
|
|
||||||
COPY backend/server/ .
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Build frontend
|
|
||||||
WORKDIR /frontend
|
|
||||||
COPY frontend/package*.json ./
|
|
||||||
RUN npm install
|
|
||||||
COPY frontend .
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Set working directory to the root directory
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
# Security: Create non-root user and assign ownership
|
|
||||||
RUN useradd -m appuser
|
|
||||||
RUN mkdir -p /backend/projects && chown -R appuser:appuser /backend/projects
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
# Start both backend and frontend
|
|
||||||
ENV BACKEND_PORT=4000
|
|
||||||
ENV FRONTEND_PORT=3000
|
|
||||||
|
|
||||||
EXPOSE 5173
|
|
||||||
EXPOSE $BACKEND_PORT
|
|
||||||
EXPOSE $FRONTEND_PORT
|
|
||||||
|
|
||||||
CMD ["sh", "-c", "cd /backend && PORT=$BACKEND_PORT npm run start & cd /frontend && PORT=$FRONTEND_PORT npm run start"]
|
|
@ -42,7 +42,7 @@ export default function CodeEditor({
|
|||||||
reactDefinitionFile: string
|
reactDefinitionFile: string
|
||||||
}) {
|
}) {
|
||||||
const socket = io(
|
const socket = io(
|
||||||
`http://localhost:${process.env.NEXT_PUBLIC_SERVER_PORT}?userId=${userData.id}&sandboxId=${sandboxData.id}`,
|
`${window.location.protocol}//${window.location.hostname}:${process.env.NEXT_PUBLIC_SERVER_PORT}?userId=${userData.id}&sandboxId=${sandboxData.id}`,
|
||||||
{
|
{
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ export default function ShareSandboxModal({
|
|||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
`${process.env.NEXT_PUBLIC_APP_URL}/code/${data.id}`
|
`${window.location.protocol}//${window.location.hostname}/code/${data.id}`
|
||||||
)
|
)
|
||||||
toast.success("Link copied to clipboard.")
|
toast.success("Link copied to clipboard.")
|
||||||
}}
|
}}
|
||||||
|
@ -45,7 +45,7 @@ export default function PreviewWindow({
|
|||||||
|
|
||||||
<PreviewButton
|
<PreviewButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(`http://localhost:5173`)
|
navigator.clipboard.writeText(`${window.location.protocol}//${window.location.hostname}:5173`)
|
||||||
toast.info("Copied preview link to clipboard")
|
toast.info("Copied preview link to clipboard")
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -73,7 +73,7 @@ export default function PreviewWindow({
|
|||||||
ref={ref}
|
ref={ref}
|
||||||
width={"100%"}
|
width={"100%"}
|
||||||
height={"100%"}
|
height={"100%"}
|
||||||
src={`http://localhost:5173`}
|
src={`${window.location.protocol}//${window.location.hostname}:5173`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
Reference in New Issue
Block a user