Skip to content

Commit

Permalink
Add Github action for testing Dockerfile builds
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev committed Oct 12, 2023
1 parent a6af140 commit 08e3cde
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Docker Compose Build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./lila-docker build
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose --manifest-path command/Cargo.toml
- name: Run tests
Expand Down
17 changes: 11 additions & 6 deletions lila-docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@
set -e

show_help() {
echo "Usage: $0 [start|stop|down]"
echo "Usage: $0 [start|stop|down|build]"
}

run_setup() {
touch .env
docker compose run --rm -it lila_docker_rs bash -c "cd /mnt && cargo run"
docker compose run --rm -it lila_docker_rs bash -c "cargo run --manifest-path /mnt/Cargo.toml"

echo "Cloning repos..."
repos=(lila lila-ws lila-db-seed lila-engine lila-fishnet lila-gif lila-search lifat scalachess api pgn-viewer chessground berserk)
for repo in "${repos[@]}"; do
[ ! -d repos/$repo ] && git clone https://github.com/lichess-org/$repo.git repos/$repo
done

cd repos/lila
git submodule update --init
cd ../..
git -C repos/lila submodule update --init

COMPOSE_PROFILES=$(all_profiles) docker compose build
run_build

echo "Compiling lila js/css..."
docker compose run --rm ui bash -c "/lila/ui/build"
Expand Down Expand Up @@ -60,6 +58,10 @@ all_profiles() {
docker compose config --profiles | xargs | sed -e 's/ /,/g'
}

run_build() {
COMPOSE_PROFILES=$(all_profiles) docker compose build
}

setup_database() {
# wait for mongodb to be ready
while ! docker exec $(docker compose ps -q mongodb) mongo --eval "db.adminCommand('ping')" > /dev/null 2>&1; do
Expand Down Expand Up @@ -93,6 +95,9 @@ case $1 in
down)
run_down
;;
build)
run_build
;;
*)
show_help
exit 1
Expand Down

0 comments on commit 08e3cde

Please sign in to comment.