Skip to content

Commit

Permalink
Merge branch 'main' into ci
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev authored Mar 29, 2024
2 parents 2a6fe99 + 026ac7e commit 0a51750
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 63 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: ./lila-docker build
- run: docker image ls
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ If you're making changes to the Scalachess library, you can have lila use it ins
Other Scalachess commands:

```bash
## formatting
docker compose run --rm -w /scalachess --entrypoint="sbt check" lila
docker compose run --rm -w /scalachess --entrypoint="sbt prepare" lila
## compile
docker compose run --rm -w /scalachess --entrypoint="sbt compile" lila
Expand Down
34 changes: 17 additions & 17 deletions command/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 73 additions & 26 deletions command/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ impl Config {
.clone()
.map(|v| v.join(","))
.unwrap_or_default();
format!(
"{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n",

vec![
to_env!(compose_profiles, compose_profiles_string),
to_env!(setup_database),
to_env!(setup_bbppairings),
Expand All @@ -103,8 +103,13 @@ impl Config {
to_env!(phone_ip),
to_env!(connection_port),
to_env!(pairing_code),
to_env!(pairing_port)
)
to_env!(pairing_port),
]
.iter()
.filter(|line| !line.is_empty())
.map(std::string::ToString::to_string)
.collect::<Vec<String>>()
.join("\n")
}
}

Expand Down Expand Up @@ -199,7 +204,7 @@ fn main() -> std::io::Result<()> {
"setup" => setup(config),
"hostname" => hostname(config),
"mobile" => mobile_setup(config),
"welcome" => welcome(),
"welcome" => welcome(config),
"flutter" => flutter(config),
"gitpod_public" => gitpod_public(),
_ => panic!("Unknown command"),
Expand Down Expand Up @@ -620,13 +625,26 @@ fn validate_string_length(input: &str, length: usize) -> Result<(), String> {
}
}

fn welcome() -> std::io::Result<()> {
fn welcome(config: Config) -> std::io::Result<()> {
intro("Your Lichess development environment is starting!")?;

note(
"Your development site will be available at:",
config
.lila_url
.unwrap_or("http://localhost:8080".to_owned()),
)?;

if Gitpod::is_host() {
info("For full documentation, see: https://lichess-org.github.io/lila-gitpod/")?;
note(
"For full documentation, see:",
"https://lichess-org.github.io/lila-gitpod/",
)?;
} else {
info("For full documentation, see: https://github.com/lichess-org/lila-docker")?;
note(
"For full documentation, see:",
"https://github.com/lichess-org/lila-docker",
)?;
}

note(
Expand Down Expand Up @@ -687,7 +705,6 @@ fn gitpod_public() -> std::io::Result<()> {
#[cfg(test)]
mod tests {
use super::*;
use std::collections::HashMap;

#[test]
fn test_repository() {
Expand Down Expand Up @@ -723,23 +740,53 @@ mod tests {
}
.to_env();

let vars = contents
.split("\n")
.flat_map(|line| line.split_once("="))
.collect::<HashMap<&str, &str>>();

assert_eq!(vars["COMPOSE_PROFILES"], "foo,bar");
assert_eq!(vars["SETUP_DATABASE"], "true");
assert_eq!(vars["SETUP_BBPPAIRINGS"], "false");
assert_eq!(vars["ENABLE_MONITORING"], "false");
assert_eq!(vars["SU_PASSWORD"], "foo");
assert_eq!(vars["PASSWORD"], "bar");
assert_eq!(vars["LILA_DOMAIN"], "baz:8080");
assert_eq!(vars["LILA_URL"], "http://baz:8080");
assert_eq!(vars["PHONE_IP"], "1.2.3.4");
assert_eq!(vars["CONNECTION_PORT"], "1234");
assert_eq!(vars["PAIRING_CODE"], "901234");
assert_eq!(vars["PAIRING_PORT"], "5678");
assert_eq!(
contents,
vec![
"COMPOSE_PROFILES=foo,bar",
"SETUP_DATABASE=true",
"SETUP_BBPPAIRINGS=false",
"ENABLE_MONITORING=false",
"SU_PASSWORD=foo",
"PASSWORD=bar",
"LILA_DOMAIN=baz:8080",
"LILA_URL=http://baz:8080",
"PHONE_IP=1.2.3.4",
"CONNECTION_PORT=1234",
"PAIRING_CODE=901234",
"PAIRING_PORT=5678"
]
.join("\n")
);
}

#[test]
fn test_env_removes_empty_lines() {
let contents = Config {
compose_profiles: None,
setup_database: None,
setup_bbppairings: None,
enable_monitoring: None,
su_password: None,
password: None,
lila_domain: Some("baz:8080".to_string()),
lila_url: Some("http://baz:8080".to_string()),
phone_ip: None,
connection_port: None,
pairing_code: None,
pairing_port: None,
}
.to_env();

assert_eq!(
contents,
vec![
"COMPOSE_PROFILES=",
"LILA_DOMAIN=baz:8080",
"LILA_URL=http://baz:8080"
]
.join("\n")
);
}

#[test]
Expand Down
3 changes: 3 additions & 0 deletions conf/lila.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ mailer.primary.port = 1025
mailer.primary.sender = "lichess.org <noreply@lichess.org>"
security.email_confirm.enabled = true

push.web.url = "http://lila_push:9054"
push.web.vapid_public_key = "BP+WcSgAQe0VNj+IJSEDkovTHk0p68sabQWTzRzyYuMgoW9ec+X3BV8o1ogavlLEObq16K7Q9jVX27nc4QtcRXk="

swiss.bbpairing = "/opt/bbpPairings/bbpPairings.exe"

kamon.enabled = ${?ENABLE_MONITORING}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ services:
- stockfish-play

fishnet_play:
image: niklasf/fishnet:2.9.0
image: niklasf/fishnet:2.9.2
restart: unless-stopped
entrypoint: /fishnet --endpoint http://lila_fishnet:9665/fishnet --max-backoff 5
networks:
Expand All @@ -151,7 +151,7 @@ services:
- stockfish-play

fishnet_analysis:
image: niklasf/fishnet:2.9.0
image: niklasf/fishnet:2.9.2
restart: unless-stopped
entrypoint: /fishnet --endpoint http://lila:9663/fishnet --max-backoff 5
networks:
Expand Down
2 changes: 1 addition & 1 deletion docker/lila-fishnet.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_3.4.0
FROM sbtscala/scala-sbt:eclipse-temurin-alpine-21.0.2_13_1.9.9_3.4.0

ENV CONFIG_FORCE_kamon_influxdb_authentication_token="secret"
ENV CONFIG_FORCE_kamon_influxdb_hostname="influxdb"
Expand Down
2 changes: 1 addition & 1 deletion docker/lila-search.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_2.13.13
FROM sbtscala/scala-sbt:eclipse-temurin-alpine-21.0.2_13_1.9.9_2.13.13

WORKDIR /lila-search

Expand Down
2 changes: 1 addition & 1 deletion docker/lila-ws.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_3.4.0
FROM sbtscala/scala-sbt:eclipse-temurin-alpine-21.0.2_13_1.9.9_3.4.0

WORKDIR /lila-ws

Expand Down
2 changes: 1 addition & 1 deletion docker/lila.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_3.4.0
FROM sbtscala/scala-sbt:eclipse-temurin-alpine-21.0.2_13_1.9.9_3.4.0

WORKDIR /lila

Expand Down
11 changes: 2 additions & 9 deletions docker/picfit.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
FROM golang:1.22.1-alpine3.19

RUN apk --no-cache add git make
FROM carbrex/thoas-picfit:latest

COPY assets/coach.png /uploads/coach.png
COPY assets/streamer.png /uploads/streamer.png

WORKDIR /opt

RUN git clone --depth 1 https://github.com/thoas/picfit.git
RUN make -C /opt/picfit build

ENTRYPOINT /opt/picfit/bin/picfit -c /mnt/config.json
ENTRYPOINT ["/picfit", "-c", "/mnt/config.json"]
4 changes: 3 additions & 1 deletion docker/ui.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:20.11.1-bookworm
FROM node:20.11.1-bookworm-slim

RUN apt update && apt install -y git && apt clean

RUN git config --global --add safe.directory /chessground
RUN git config --global --add safe.directory /lila
Expand Down
13 changes: 9 additions & 4 deletions lila-docker
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ run_setup() {
docker compose build
docker compose --profile utils build
docker compose up -d
docker compose run --rm ui /lila/ui/build --debug

run_ui_build --update

setup_bbppairings
setup_database
Expand Down Expand Up @@ -43,6 +44,10 @@ build_all_profiles() {
COMPOSE_PROFILES=$(all_profiles) docker compose build
}

run_ui_build() {
docker compose run --rm ui /lila/ui/build --clean --debug --split $@
}

setup_database() {
if [ "$SETUP_DATABASE" != "true" ]; then
echo "Skipping database setup"
Expand Down Expand Up @@ -98,8 +103,8 @@ run_hostname() {
rust_cmd hostname

if [ ! -z "$(docker compose ps -a --services | xargs)" ]; then
docker compose down lila lila_ws mobile nginx
docker compose up -d lila lila_ws mobile nginx
docker compose down lila lila_ws nginx
docker compose up -d lila lila_ws nginx
fi
}

Expand Down Expand Up @@ -190,7 +195,7 @@ case "$@" in
docker compose restart lila
;;
ui)
docker compose run --rm ui /lila/ui/build --debug --watch
run_ui_build --rebuild
;;
"gitpod public")
rust_cmd gitpod_public
Expand Down

0 comments on commit 0a51750

Please sign in to comment.