Skip to content

Commit

Permalink
Configuration cleanup (#26)
Browse files Browse the repository at this point in the history
* Cleanup conf setup

* https for gitpod
  • Loading branch information
fitztrev authored Nov 16, 2023
1 parent 17b7626 commit f7521b8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.env
.pnpm-store

conf/lila.conf
conf/lila-ws.conf

command/.cargo
command/target

Expand Down
2 changes: 1 addition & 1 deletion conf/lila-ws.original.conf → conf/lila-ws.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}
12 changes: 6 additions & 6 deletions conf/lila.original.conf → conf/lila.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 <noreply@localhost>"
mailer.primary.sender = "lichess.org <noreply@lichess.org>"
security.email_confirm.enabled = true

swiss.bbpairing = "/opt/bbpPairings/bbpPairings.exe"
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 6 additions & 16 deletions lila-docker
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f7521b8

Please sign in to comment.