Skip to content

Commit 04eceab

Browse files
committed
Add option to use prebuilt lila-ws image
1 parent b4dd5d4 commit 04eceab

4 files changed

Lines changed: 94 additions & 26 deletions

File tree

command/src/main.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const DEFAULT_PASSWORD: &str = "password";
2929
struct Config {
3030
quick_setup: Option<bool>,
3131
compose_profiles: Option<Vec<String>>,
32+
lila_ws_container: Option<String>,
3233
setup_database: Option<bool>,
3334
setup_bbppairings: Option<bool>,
3435
mock_email: Option<bool>,
@@ -77,6 +78,7 @@ impl Config {
7778
let Self {
7879
quick_setup,
7980
compose_profiles,
81+
lila_ws_container,
8082
setup_database,
8183
setup_bbppairings,
8284
mock_email,
@@ -96,6 +98,7 @@ impl Config {
9698
vec![
9799
to_env!(quick_setup),
98100
to_env!(compose_profiles, compose_profiles_string),
101+
to_env!(lila_ws_container),
99102
to_env!(setup_database),
100103
to_env!(setup_bbppairings),
101104
to_env!(mock_email),
@@ -336,6 +339,17 @@ fn setup(mut config: Config, first_setup: bool, noninteractive: bool) -> std::io
336339
.iter()
337340
.any(|service| service.compose_profile == Some(vec!["monitoring"])),
338341
);
342+
343+
config.lila_ws_container = Some(
344+
if services
345+
.iter()
346+
.any(|service| service.compose_profile == Some(vec!["lila-ws-build"]))
347+
{
348+
"build".to_string()
349+
} else {
350+
"image".to_string()
351+
},
352+
);
339353
}
340354

341355
if Gitpod::is_host()
@@ -379,10 +393,7 @@ fn setup(mut config: Config, first_setup: bool, noninteractive: bool) -> std::io
379393
if !is_quick_setup {
380394
create_placeholder_dirs();
381395

382-
let mut repos_to_clone: Vec<Repository> = vec![
383-
Repository::new("lichess-org", "lila"),
384-
Repository::new("lichess-org", "lila-ws"),
385-
];
396+
let mut repos_to_clone: Vec<Repository> = vec![Repository::new("lichess-org", "lila")];
386397

387398
if config.setup_database.unwrap_or_default() {
388399
repos_to_clone.push(Repository::new("lichess-org", "lila-db-seed"));
@@ -517,6 +528,14 @@ fn prompt_for_services() -> Result<Vec<OptionalService<'static>>, Error> {
517528
"Database admin interface",
518529
"Mongo Express for viewing database structure and data",
519530
)
531+
.item(
532+
OptionalService {
533+
compose_profile: vec!["lila-ws-build"].into(),
534+
repositories: vec![Repository::new("lichess-org", "lila-ws")].into(),
535+
},
536+
"Websocket source code",
537+
"Only needed if you want to make changes, otherwise a prebuilt lila-ws image will be used",
538+
)
520539
.item(
521540
OptionalService {
522541
compose_profile: vec!["email"].into(),
@@ -787,6 +806,7 @@ mod tests {
787806
let contents = Config {
788807
quick_setup: Some(true),
789808
compose_profiles: Some(vec!["foo".to_string(), "bar".to_string()]),
809+
lila_ws_container: Some("image".to_string()),
790810
setup_database: Some(true),
791811
setup_bbppairings: Some(false),
792812
mock_email: Some(false),
@@ -805,6 +825,7 @@ mod tests {
805825
vec![
806826
"QUICK_SETUP=true",
807827
"COMPOSE_PROFILES=foo,bar",
828+
"LILA_WS_CONTAINER=image",
808829
"SETUP_DATABASE=true",
809830
"SETUP_BBPPAIRINGS=false",
810831
"MOCK_EMAIL=false",
@@ -825,6 +846,7 @@ mod tests {
825846
let contents = Config {
826847
quick_setup: None,
827848
compose_profiles: None,
849+
lila_ws_container: None,
828850
setup_database: None,
829851
setup_bbppairings: None,
830852
mock_email: None,

compose-lila-ws-build.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
lila_ws:
3+
build:
4+
context: docker
5+
args:
6+
USER_ID: ${USER_ID}
7+
GROUP_ID: ${GROUP_ID}
8+
dockerfile: sbt.Dockerfile
9+
user: ${USER_ID}:${GROUP_ID}
10+
working_dir: /lila-ws
11+
entrypoint: sbt run -Dconfig.file=/lila-ws.conf
12+
restart: unless-stopped
13+
environment:
14+
- LILA_URL=${LILA_URL:-http://localhost:8080}
15+
- ENABLE_MONITORING=${ENABLE_MONITORING:-false}
16+
volumes:
17+
- ./repos/lila-ws:/lila-ws
18+
- ./conf/lila-ws.conf:/lila-ws.conf
19+
profiles:
20+
- lila-ws-build

compose-lila-ws-image.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
lila_ws:
3+
image: ghcr.io/lichess-org/lila-ws:latest
4+
restart: unless-stopped
5+
environment:
6+
- CONFIG_FORCE_csrf.origin=${LILA_URL:-http://localhost:8080}
7+
- CONFIG_FORCE_kamon.enabled=${ENABLE_MONITORING:-false}
8+
- CONFIG_FORCE_influxdb.hostname=influxdb
9+
- CONFIG_FORCE_influxdb.authentication.token=secret
10+
- CONFIG_FORCE_mongo_uri=mongodb://mongo:27017/lichess?appName=lila-ws
11+
- CONFIG_FORCE_redis.uri=redis://redis
12+
profiles:
13+
- base

docker-compose.yml renamed to compose.yml

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
include:
2+
- compose-lila-ws-${LILA_WS_CONTAINER:-image}.yml
3+
14
services:
25
mongodb:
36
image: mongo:7.0.20-jammy
@@ -55,25 +58,38 @@ services:
5558
profiles:
5659
- base
5760

58-
lila_ws:
59-
build:
60-
context: docker
61-
args:
62-
USER_ID: ${USER_ID}
63-
GROUP_ID: ${GROUP_ID}
64-
dockerfile: sbt.Dockerfile
65-
user: ${USER_ID}:${GROUP_ID}
66-
working_dir: /lila-ws
67-
entrypoint: sbt run -Dconfig.file=/lila-ws.conf
68-
restart: unless-stopped
69-
environment:
70-
- LILA_URL=${LILA_URL:-http://localhost:8080}
71-
- ENABLE_MONITORING=${ENABLE_MONITORING:-false}
72-
volumes:
73-
- ./repos/lila-ws:/lila-ws
74-
- ./conf/lila-ws.conf:/lila-ws.conf
75-
profiles:
76-
- base
61+
# lila_ws:
62+
# build:
63+
# context: docker
64+
# args:
65+
# USER_ID: ${USER_ID}
66+
# GROUP_ID: ${GROUP_ID}
67+
# dockerfile: sbt.Dockerfile
68+
# user: ${USER_ID}:${GROUP_ID}
69+
# working_dir: /lila-ws
70+
# entrypoint: sbt run -Dconfig.file=/lila-ws.conf
71+
# restart: unless-stopped
72+
# environment:
73+
# - LILA_URL=${LILA_URL:-http://localhost:8080}
74+
# - ENABLE_MONITORING=${ENABLE_MONITORING:-false}
75+
# volumes:
76+
# - ./repos/lila-ws:/lila-ws
77+
# - ./conf/lila-ws.conf:/lila-ws.conf
78+
# profiles:
79+
# - lila-ws-build
80+
81+
# lila_ws:
82+
# image: ghcr.io/lichess-org/lila-ws:latest
83+
# restart: unless-stopped
84+
# environment:
85+
# - CONFIG_FORCE_csrf.origin=${LILA_URL:-http://localhost:8080}
86+
# - CONFIG_FORCE_kamon.enabled=${ENABLE_MONITORING:-false}
87+
# - CONFIG_FORCE_influxdb.hostname=influxdb
88+
# - CONFIG_FORCE_influxdb.authentication.token=secret
89+
# - CONFIG_FORCE_mongo_uri=mongodb://mongo:27017/lichess?appName=lila-ws
90+
# - CONFIG_FORCE_redis.uri=redis://redis
91+
# profiles:
92+
# - base
7793

7894
nginx:
7995
image: nginx:1.27.5-alpine3.21-slim
@@ -84,9 +100,6 @@ services:
84100
- ./conf/nginx.conf:/etc/nginx/conf.d/default.conf
85101
- ./repos/lila/public:/lila/public
86102
- ./nginx:/nginx
87-
depends_on:
88-
- lila
89-
- lila_ws
90103
profiles:
91104
- base
92105

0 commit comments

Comments
 (0)