Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docker compose #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@

<a href="https://www.producthunt.com/posts/judge0-ide" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=179885&theme=light" alt="" height="43px" /></a>

## Quickstart

Judge0 IDE up and running quickly:

1. **Setting Host and Port**
To ensure Judge0 IDE connects to the correct backend host, configure the `defaultUrl` in `ide/js` based on your environment:

- **Local Setup**: If running Judge0 IDE locally, set `defaultUrl` to `localhost:port`.
- **Remote Setup**: If deploying to a remote server, set `defaultUrl` to your server's address, e.g., `remote:port`.

Adjusting this setting will allow the IDE to connect properly depending on whether it is running locally or remotely.

2. **Start Judge0 IDE**
```bash
docker-compose up -d db redis
sleep 10s
docker-compose up -d
sleep 5s
```

By default, the IDE web interface will open on port 8085. You can change this in `docker-compose.yml`. If you modify the port or host for Nginx, remember to also update the `defaultUrl` in `ide/js`.

## About
[**Judge0 IDE**](https://ide.judge0.com) is a free and open-source online code editor that allows you to write and execute code from a rich set of languages. It's perfect for anybody who just wants to quickly write and run some code without opening a full-featured IDE on their computer. Moreover, it is also useful for teaching and learning or just trying out a new language.

Expand Down
55 changes: 55 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
x-logging:
&default-logging
logging:
driver: json-file
options:
max-size: 100M

services:
nginx:
image: nginx:latest
container_name: nginx_server
ports:
- "8085:80"
volumes:
- ./nginx_default:/etc/nginx/conf.d/default.conf:ro
- ./:/var/www/html
restart: always

server:
image: judge0/judge0:1.13.1
volumes:
- ./judge0.conf:/judge0.conf:ro
privileged: true
<<: *default-logging
restart: always

workers:
image: judge0/judge0:1.13.1
command: ["./scripts/workers"]
volumes:
- ./judge0.conf:/judge0.conf:ro
privileged: true
<<: *default-logging
restart: always

db:
image: postgres:16.2
env_file: judge0.conf
volumes:
- data:/var/lib/postgresql/data/
<<: *default-logging
restart: always

redis:
image: redis:7.2.4
command: [
"bash", "-c",
'docker-entrypoint.sh --appendonly no --requirepass "$$REDIS_PASSWORD"'
]
env_file: judge0.conf
<<: *default-logging
restart: always

volumes:
data:
1 change: 1 addition & 0 deletions js/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const AUTH_HEADERS = API_KEY ? {
} : {};

var defaultUrl = localStorageGetItem("api-url") || "https://judge0-ce.p.rapidapi.com";
// var defaultUrl = localStorageGetItem("api-url") || "http://localhost:8085/api"; example for local server
var extraApiUrl = "https://judge0-extra-ce.p.rapidapi.com";

if (location.hostname == "ide.judge0.com") {
Expand Down
Loading