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 9, 2024
2 parents 8143e2f + d2fadee commit b841f6c
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 18 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ To remove the containers:

Always available:

| Service | URL |
| ------------------ | ----------------------------------- |
| Main lila instance | http://localhost:8080/ |
| Mongodb manager | http://localhost:8081/ (admin/pass) |
| Email inbox | http://localhost:8025/ |
| Service | URL |
| ------------------ | ---------------------- |
| Main lila instance | http://localhost:8080/ |
| Mongodb manager | http://localhost:8081/ |
| Email inbox | http://localhost:8025/ |

Depending on which optional services you start:

Expand Down
57 changes: 53 additions & 4 deletions command/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

use cliclack::{
confirm, input, intro,
log::{self, info, step},
log::{error, info, step},
multiselect, note, outro, select, spinner,
};
use local_ip_address::local_ip;
use serde::{Deserialize, Serialize};
use std::process::Command;
use std::{
format,
io::Error,
io::{Error, ErrorKind},
path::{Path, PathBuf},
process::Command,
};

const BANNER: &str = r"
Expand Down Expand Up @@ -200,6 +200,8 @@ fn main() -> std::io::Result<()> {
"hostname" => hostname(config),
"mobile" => mobile_setup(config),
"welcome" => welcome(),
"flutter" => flutter(config),
"gitpod_public" => gitpod_public(),
_ => panic!("Unknown command"),
}
}
Expand Down Expand Up @@ -528,7 +530,7 @@ fn prompt_for_optional_services() -> Result<Vec<OptionalService<'static>>, Error

fn hostname(mut config: Config) -> std::io::Result<()> {
if Gitpod::is_host() {
return log::error("Setting of hostname not available on Gitpod");
return error("Setting of hostname not available on Gitpod");
}

let local_ip = match local_ip() {
Expand Down Expand Up @@ -619,6 +621,53 @@ fn welcome() -> std::io::Result<()> {
outro("🚀")
}

fn flutter(config: Config) -> std::io::Result<()> {
let url = if Gitpod::is_host() {
gitpod_public()?;
Gitpod::load().url
} else {
config.lila_url.expect("Missing lila_url")
};

if url.contains("localhost") {
error("To run the Flutter app against your development site, change the lila URL to a hostname that can be resolved from other network devices (instead of `localhost`).")?;
return note("To fix, run:", "./lila-docker hostname");
}

outro("On your local machine, start Flutter with this command:")?;
println!("\nflutter run -v \\\n --dart-define LICHESS_HOST={url} \\\n --dart-define LICHESS_WS_HOST={url}");

Ok(())
}

fn gitpod_public() -> std::io::Result<()> {
if !Gitpod::is_host() {
return Err(std::io::Error::new(
ErrorKind::Other,
"This command is only available on Gitpod",
));
}

let mut progress = spinner();
progress.start("Making http port 8080 publicly accessible...");

let mut cmd = Command::new("gp");
cmd.arg("ports").arg("visibility").arg("8080:public");

let output = cmd.output().expect("Command failed");
let stdout = String::from_utf8(output.stdout).expect("Failed to parse stdout");

if !stdout.contains("port 8080 is now public") {
return Err(std::io::Error::new(
ErrorKind::Other,
"Failed to make port 8080 public",
));
}

progress.stop("✓ Port 8080 is now publicly accessible");
outro(Gitpod::load().url)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion conf/lila.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ net.socket.domains = [ ${?LILA_DOMAIN} ]
net.asset.base_url = ${?LILA_URL}
net.asset.base_url_internal = "http://nginx"
net.base_url = ${?LILA_URL}
net.ratelimit = false
# net.ratelimit = false

mongodb.uri = "mongodb://mongodb?appName=lila"
redis.uri = "redis://redis"
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
mongodb:
image: mongo:5.0.24-focal
image: mongo:5.0.25-focal
restart: unless-stopped
networks:
- lila-network
Expand Down Expand Up @@ -252,7 +252,7 @@ services:
- thumbnails

mailpit:
image: axllent/mailpit:v1.14.0
image: axllent/mailpit:v1.14.1
restart: unless-stopped
ports:
- 8025:8025
Expand All @@ -265,6 +265,7 @@ services:
ports:
- 8081:8081
environment:
- ME_CONFIG_BASICAUTH=false
- ME_CONFIG_MONGODB_SERVER=mongodb
networks:
- lila-network
Expand Down
2 changes: 1 addition & 1 deletion docker/mobile.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/cirruslabs/flutter:3.19.1
FROM ghcr.io/cirruslabs/flutter:3.19.3

RUN apt-get update && \
apt-get install --yes clang cmake libgtk-3-dev ninja-build pkg-config && \
Expand Down
2 changes: 1 addition & 1 deletion docker/picfit.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.0-alpine3.19
FROM golang:1.22.1-alpine3.19

RUN apk --no-cache add git make

Expand Down
4 changes: 2 additions & 2 deletions docs/gitpod-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
cd command

## test with no PR specified
GITPOD_WORKSPACE_URL=https://example.com \
GITPOD_WORKSPACE_URL=https://test.example.com \
GITPOD_WORKSPACE_CONTEXT={} \
cargo run -- setup

## test with PR specified
GITPOD_WORKSPACE_URL=https://example.com \
GITPOD_WORKSPACE_URL=https://test.example.com \
GITPOD_WORKSPACE_CONTEXT='{"envvars":[{"name":"LILA_PR","value":"14738"}]}' \
cargo run -- setup
```
Expand Down
12 changes: 10 additions & 2 deletions lila-docker
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ rust_cmd() {
cargo build --release --manifest-path command/Cargo.toml
./command/target/release/command "$@"
elif [ "$(uname)" = "Darwin" ]; then
docker run --rm -v "$PWD/command:/command" -w /command messense/cargo-zigbuild:0.18.1 \
docker run --rm -v "$PWD/command:/command" -w /command messense/cargo-zigbuild:0.18.3 \
cargo zigbuild --release --target universal2-apple-darwin
./command/target/universal2-apple-darwin/release/command "$@"
else
docker run --rm -v "$PWD/command:/command" -w /command messense/cargo-zigbuild:0.18.1 \
docker run --rm -v "$PWD/command:/command" -w /command messense/cargo-zigbuild:0.18.3 \
cargo zigbuild --release
./command/target/release/command "$@"
fi
Expand All @@ -142,9 +142,11 @@ show_help() {
echo " format Run the code formatter to match Lichess code style"
echo " hostname Set the hostname to something different than the default localhost"
echo " mobile For mobile app development.Pair and connect to a mobile device"
echo " flutter Get the 'flutter run' command with the URL arguments pre-configured"
echo " db Reset and re-seed the database with fresh fake data"
echo " lila clean Run 'sbt clean' in the lila container. Useful if there are compilation errors"
echo " lila restart Restart the lila container to apply changes to the codebase"
echo " gitpod public Make http port 8080 public on the Gitpod instance"
echo " ui Compile the frontend code. Runs in watch mode to automatically recompile on changes"
}

Expand Down Expand Up @@ -189,6 +191,12 @@ case "$@" in
ui)
docker compose run --rm ui /lila/ui/build --debug --watch
;;
"gitpod public")
rust_cmd gitpod_public
;;
"flutter")
rust_cmd flutter
;;
*)
show_help
exit 1
Expand Down

0 comments on commit b841f6c

Please sign in to comment.