Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ DATABASE_URL=postgres://codesce:changeme@database:5432/codesce?sslmode=disable
# Frontend
FRONTEND_PORT=3000
VITE_API_URL=http://localhost:6767

# Redis
REDIS_URL=redis://redis:6379
WORKER_COUNT=4
EXECUTION_TIMEOUT=10
SANDBOX_MEMORY_LIMIT=256
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ COPY --from=build /bin/server /bin/server
EXPOSE 6767

CMD ["/bin/server"]


FROM python3.12-slim

WORKDIR /app

# entrypoint lets us pipe stdin and returns stdout

ENTRYPOINT ["python", "/code/solution.py"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stuff should be in its own file Dockerfile.python since the runner is a separate service from the Go backend

23 changes: 22 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,27 @@ services:
database:
ports:
- "${DB_PORT:-5432}:5432"

redis:
ports:
- "6379:6379"
executor:
# docker can only access files in /executor
build:
context: ./executor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
context: ./executor
context: .

typo in the issue

dockerfile: Dockerfile.dev
environment:
REDIS_URL: ${REDIS_URL}
DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/${POSTGRES_DB}?sslmode=disable
WORKER_COUNT: ${WORKER_COUNT}
EXECUTION_TIMEOUT: ${EXECUTION_TIMEOUT}
SANDBOX_MEMORY_LIMIT: ${SANDBOX_MEMORY_LIMIT}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
redis:
condition: service_healthy
database:
condition: service_healthy
backend:
build:
context: .
Expand All @@ -11,6 +31,7 @@ services:
GIN_MODE: debug
PORT: ${BACKEND_PORT:-6767}
DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/${POSTGRES_DB}?sslmode=disable
REDIS_URL: ${REDIS_URL}
volumes:
- .:/app
- go-mod-cache:/go/pkg/mod
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
services:
# each service is a container
redis:
image: redis:7-alpine
ports:
- "6379:6379"
# will return pong if up
healthcheck:
test: ["CMD-SHELL", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
executor:
build:
context: ./executor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
context: ./executor
context: .

typo in the issue

dockerfile: Dockerfile
environment:
REDIS_URL: ${REDIS_URL}
DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/${POSTGRES_DB}?sslmode=disable
WORKER_COUNT: ${WORKER_COUNT}
EXECUTION_TIMEOUT: ${EXECUTION_TIMEOUT}
SANDBOX_MEMORY_LIMIT: ${SANDBOX_MEMORY_LIMIT}
# executor allows us to run other containers
# left side is file from host, right side is file inside container
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
redis:
condition: service_healthy
database:
condition: service_healthy
database:
image: postgres:16-alpine
container_name: codesce-db
Expand All @@ -25,6 +55,7 @@ services:
DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/${POSTGRES_DB}?sslmode=disable
GIN_MODE: ${GIN_MODE:-release}
PORT: ${BACKEND_PORT:-6767}
REDIS_URL: ${REDIS_URL}
ports:
- "${BACKEND_PORT:-6767}:6767"
depends_on:
Expand Down