Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
22 changes: 21 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@ services:
database:
ports:
- "${DB_PORT:-5432}:5432"

redis:
ports:
- "6379:6379"
executor:
build:
context: .
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 +30,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: .
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
7 changes: 7 additions & 0 deletions docker/Dockerfile.python
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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.

all of this stuff will be invoked by the Go service when queried, all this file needs to have is the image line