Skip to content

Commit

Permalink
test: ✅ update and run docker example
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason0729 committed Dec 6, 2023
1 parent bfa944c commit 5b9c754
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 49 deletions.
6 changes: 3 additions & 3 deletions backend/src/init/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ pub async fn init(config: &GlobalConfig) {
fs::File::create(PathBuf::from(config.database.path.clone()))
.await
.unwrap();
first_migration(config).await;

let db: DatabaseConnection = Database::connect(&uri).await.unwrap();

first_migration(config,&db).await;
DB.set(db).unwrap();

println!("Database created");
}
}
Expand All @@ -41,8 +42,7 @@ fn hash(config: &GlobalConfig, src: &str) -> Vec<u8> {
.to_vec()
}

pub async fn first_migration(config: &GlobalConfig) {
let db = DB.get().unwrap();
pub async fn first_migration(config: &GlobalConfig,db:&DatabaseConnection) {
let mut perm = UserPermBytes::default();

perm.grant_link(true);
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions docker/production/backend/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bind_address = "0.0.0.0:8081"
log_level = 0

[database]
path = "database/backend.sqlite"
salt = "be sure to change it"

[[judger]]
name = "http://127.0.0.1:8080"
type = "static"

[grpc]
trust_x_forwarded_for = false
public_pem = "cert.pem"
private_pem = "key.pem"
6 changes: 3 additions & 3 deletions docker/production/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ services:
container_name: mdoj-backend
image: ghcr.io/mdcpp/mdoj:backend
volumes:
- ./database/:/database/
- ./config/:/config/
- ./judger/:/config/
- ./judger/:/database/
networks:
- backend
- judger
Expand All @@ -32,7 +32,7 @@ services:
image: ghcr.io/mdcpp/mdoj:judger
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup
- ./config/:/config/
- ./judger/:/config/
networks:
- judger
networks:
Expand Down
25 changes: 25 additions & 0 deletions docker/production/judger/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
log_level = 0

[runtime]
temp = ".temp"
bind = "0.0.0.0:8080"
accuracy = 50000
root_cgroup = "mdoj/c."

[platform]
cpu_time_multiplier = 1.0
available_memory = 1073741824
output_limit = 33554432

[nsjail]
runtime = "./nsjail-3.1"
rootless = false
log = "/dev/null"
cgroup_version = "v2"

[plugin]
path = "plugins"

[kernel]
kernel_hz = 1000
tickless = false
Empty file.
15 changes: 15 additions & 0 deletions docker/quickstart/backend/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bind_address = "0.0.0.0:8081"
log_level = 0

[database]
path = "database/backend.sqlite"
salt = "be sure to change it"

[[judger]]
name = "http://127.0.0.1:8080"
type = "static"

[grpc]
trust_x_forwarded_for = false
public_pem = "cert.pem"
private_pem = "key.pem"
6 changes: 3 additions & 3 deletions docker/quickstart/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ services:
container_name: mdoj-backend
image: ghcr.io/mdcpp/mdoj:backend
volumes:
- ./database/:/database/
- ./config/:/config/
- ./judger/:/config/
- ./judger/:/database/
networks:
- backend
- judger
Expand All @@ -32,7 +32,7 @@ services:
image: ghcr.io/mdcpp/mdoj:judger
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup
- ./config/:/config/
- ./judger/:/config/
networks:
- judger
networks:
Expand Down
25 changes: 25 additions & 0 deletions docker/quickstart/judger/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
log_level = 0

[runtime]
temp = ".temp"
bind = "0.0.0.0:8080"
accuracy = 50000
root_cgroup = "mdoj/c."

[platform]
cpu_time_multiplier = 1.0
available_memory = 1073741824
output_limit = 33554432

[nsjail]
runtime = "./nsjail-3.1"
rootless = false
log = "/dev/null"
cgroup_version = "v2"

[plugin]
path = "plugins"

[kernel]
kernel_hz = 1000
tickless = false
40 changes: 0 additions & 40 deletions docker/simple/docker-compose.yml

This file was deleted.

0 comments on commit 5b9c754

Please sign in to comment.