diff --git a/.gitignore b/.gitignore index 039b7fd3..c1ad0f5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,6 @@ .env .pnpm-store -conf/lila.conf -conf/lila-ws.conf - command/.cargo command/target diff --git a/conf/lila-ws.original.conf b/conf/lila-ws.conf similarity index 71% rename from conf/lila-ws.original.conf rename to conf/lila-ws.conf index f44e0858..291d2b3f 100644 --- a/conf/lila-ws.original.conf +++ b/conf/lila-ws.conf @@ -3,4 +3,4 @@ include "application" mongo.uri = "mongodb://mongodb:27017/lichess?appName=lila-ws" redis.uri = "redis://redis" -csrf.origin = "http://localhost:8080" +csrf.origin = ${?SCHEME}"://"${?LILA_DOMAIN} diff --git a/conf/lila.original.conf b/conf/lila.conf similarity index 72% rename from conf/lila.original.conf rename to conf/lila.conf index 09c855d2..b8ccba1d 100644 --- a/conf/lila.original.conf +++ b/conf/lila.conf @@ -4,11 +4,11 @@ include "version" user.password.bpass.secret = "9qEYN0ThHer1KWLNekA76Q==" net.site.name = "lila" -net.domain = "localhost:8080" -net.socket.domains = [ "localhost:8080" ] -net.asset.base_url = "http://localhost:8080" +net.domain = ${?LILA_DOMAIN} +net.socket.domains = [ ${?LILA_DOMAIN} ] +net.asset.base_url = ${?SCHEME}"://"${?LILA_DOMAIN} net.asset.base_url_internal = "http://nginx" -net.base_url = "http://localhost:8080" +net.base_url = ${?SCHEME}"://"${?LILA_DOMAIN} mongodb.uri = "mongodb://mongodb?appName=lila" redis.uri = "redis://redis" @@ -18,14 +18,14 @@ game.gifUrl = "http://lila_gif:6175" search.enabled = true search.endpoint = "http://lila_search:9673" -memo.picfit.endpointGet = "http://localhost:3001" +memo.picfit.endpointGet = ${?SCHEME}"://"${?PICFIT_DOMAIN} memo.picfit.endpointPost = "http://picfit:3001" mailer.primary.mock = false mailer.primary.tls = false mailer.primary.host = "mailpit" mailer.primary.port = 1025 -mailer.primary.sender = "lichess.org " +mailer.primary.sender = "lichess.org " security.email_confirm.enabled = true swiss.bbpairing = "/opt/bbpPairings/bbpPairings.exe" diff --git a/docker-compose.yml b/docker-compose.yml index a2d86d70..5ac59104 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,10 @@ services: restart: unless-stopped networks: - lila-network + environment: + - SCHEME=${SCHEME:-http} + - LILA_DOMAIN=${LILA_DOMAIN:-localhost:8080} + - PICFIT_DOMAIN=${PICFIT_DOMAIN:-localhost:3001} volumes: - ./repos/lila:/lila - ./repos/chessground:/chessground @@ -36,6 +40,9 @@ services: restart: unless-stopped networks: - lila-network + environment: + - SCHEME=${SCHEME:-http} + - LILA_DOMAIN=${LILA_DOMAIN:-localhost:8080} volumes: - ./repos/lila-ws:/lila-ws - ./conf/lila-ws.conf:/lila-ws.conf diff --git a/lila-docker b/lila-docker index 1004c262..232c4bd1 100755 --- a/lila-docker +++ b/lila-docker @@ -1,6 +1,12 @@ #!/bin/bash set -e +if [ ! -z "$GITPOD_WORKSPACE_ID" ]; then + export SCHEME=https + export LILA_DOMAIN=$(gp url 8080 | cut -c9-) + export PICFIT_DOMAIN=$(gp url 3001 | cut -c9-) +fi + run_setup() { touch .env docker compose run --rm -it lila_docker_rs bash -c "cargo run --manifest-path /mnt/Cargo.toml" @@ -28,8 +34,6 @@ run_setup() { git -C repos/lila submodule update --init - run_setup_config - docker compose build # separate build specifically for utils profile otherwise its Dockerfile changes won't be detected docker compose --profile utils build @@ -44,20 +48,6 @@ run_setup() { fi } -run_setup_config() { - echo "Copying config files..." - cp conf/lila.original.conf conf/lila.conf - cp conf/lila-ws.original.conf conf/lila-ws.conf - - # if we're running on Gitpod, we need to replace the localhost URLs with the Gitpod URLs - if [ ! -z "$GITPOD_WORKSPACE_ID" ]; then - echo "Replacing localhost URLs with Gitpod URLs..." - find ./conf/lila.conf ./conf/lila-ws.conf -type f -exec sed -i "s/http:\/\/localhost:8080/$(gp url 8080 | sed 's/\//\\\//g')/g" {} \; - find ./conf/lila.conf ./conf/lila-ws.conf -type f -exec sed -i "s/http:\/\/localhost:3001/$(gp url 3001 | sed 's/\//\\\//g')/g" {} \; - find ./conf/lila.conf ./conf/lila-ws.conf -type f -exec sed -i "s/localhost:8080/$(gp url 8080 | cut -c9-)/g" {} \; - fi -} - run_start() { if [ -z "$(docker compose ps -a --services | xargs)" ]; then run_setup