Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ COPY --from=build /bin/server /bin/server

EXPOSE 6767

CMD ["/bin/server"]
CMD ["/bin/server"]
31 changes: 31 additions & 0 deletions Dockerfile.executor
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# typing everythig up manually: high cortisol
# COPY AND PASTE FROM OTHER FILES: low cortisol

# executor dockerfile (go) thinking monkey....

# --- Build stage ---

# go image with compiler, names it build
FROM golang:1.25-alpine AS build

# set working directory inside container
WORKDIR /app

# copy two dependency files for main.go into ./ inside the container aka /app
COPY cmd/runner/go.mod cmd/runner/go.sum ./
RUN go mod download

# copy source code (left) into image (right)
COPY cmd/runner/ .

# compiles code in /app into service called runner
RUN go build -o runner .

# --- Production stage ---
FROM alpine:3.20 AS production

WORKDIR /app

COPY --from=build /app/runner /app/runner

CMD ["/app/runner"]
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.executor
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.executor
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
1 change: 1 addition & 0 deletions docker/Dockerfile.python
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM python3.12-slim