From 986e09e070a96c6e4c12c7a8cb7285c03b438d02 Mon Sep 17 00:00:00 2001 From: Xavier Mitault Date: Wed, 26 Jul 2023 14:03:36 +0200 Subject: [PATCH 1/3] Add dockerfile + how to run it --- Dockerfile | 10 ++++++++++ README.md | 1 + run.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 Dockerfile create mode 100755 run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..657063ef3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM docker.io/archlinux:latest +RUN pacman-key --init +RUN pacman -Syu --noconfirm \ + dotnet-sdk-6.0 \ + mesa \ + && pacman -Scc --noconfirm +COPY . /app/ +WORKDIR /app/Chess-Challenge/ +RUN cd /app/ && dotnet build +CMD dotnet run diff --git a/README.md b/README.md index dcaace30a..a48f6dbff 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ All names (variables, functions, etc.) are counted as a single token, regardless * Now use the command: `dotnet run` * This should launch the project. If not, open an issue with any error messages and relevant info. * [Running on Linux](https://github.com/SebLague/Chess-Challenge/discussions/3) + * or with the Dockerfile provided (run: `./run.sh` (you need to have docker or podman installed on your machine)) * Issues with illegal moves or errors when making/undoing a move * Make sure that you are making and undoing moves in the correct order, and that you don't forget to undo a move when exiting early from a function for example. * How to tell what colour MyBot is playing diff --git a/run.sh b/run.sh new file mode 100755 index 000000000..570d7c81d --- /dev/null +++ b/run.sh @@ -0,0 +1,31 @@ +#!/bin/bash -e + +if grep -q 'Arch' /etc/os-release; then + unset DBUS_SESSION_BUS_ADDRESS +fi + +if [ -z "$WAYLAND_DISPLAY" ]; then + CRI_OPT+=( + --network host + -e XAUTHORITY=/app/.Xauthority + -v "$XAUTHORITY:/app/.Xauthority:ro" + ) +fi + +CRI="$(command -v podman || command -v docker)" + +if ! "${CRI[@]}" image ls &>/dev/null; then + CRI=(sudo "${CRI[@]}") +fi + +"${CRI[@]}" build . -t chess + +"${CRI[@]}" run --rm --name chess \ + "${CRI_OPT[@]}" \ + --device /dev/dri/ \ + -e DISPLAY \ + -e XDG_RUNTIME_DIR \ + -v /dev/shm/:/dev/shm/ \ + -v /tmp/.X11-unix/:/tmp/.X11-unix/ \ + -v "$XDG_RUNTIME_DIR:$XDG_RUNTIME_DIR" \ + chess From c99205c24d3820c5d25e25934e183943c84ec82e Mon Sep 17 00:00:00 2001 From: Xavier Mitault Date: Wed, 26 Jul 2023 14:05:37 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a48f6dbff..f3ae6c7a7 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ All names (variables, functions, etc.) are counted as a single token, regardless * Now use the command: `dotnet run` * This should launch the project. If not, open an issue with any error messages and relevant info. * [Running on Linux](https://github.com/SebLague/Chess-Challenge/discussions/3) - * or with the Dockerfile provided (run: `./run.sh` (you need to have docker or podman installed on your machine)) + * Or with the Dockerfile provided (run: `./run.sh` (you need to have docker or podman installed on your machine)) * Issues with illegal moves or errors when making/undoing a move * Make sure that you are making and undoing moves in the correct order, and that you don't forget to undo a move when exiting early from a function for example. * How to tell what colour MyBot is playing From a395508ccc0df1ea97c6f6a256f529123b429c0a Mon Sep 17 00:00:00 2001 From: Xavier Mitault Date: Wed, 26 Jul 2023 14:06:16 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f3ae6c7a7..40b5a35ab 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,7 @@ All names (variables, functions, etc.) are counted as a single token, regardless * For example: `cd C:\Users\MyName\Desktop\Chess-Challenge\Chess-Challenge` * Now use the command: `dotnet run` * This should launch the project. If not, open an issue with any error messages and relevant info. -* [Running on Linux](https://github.com/SebLague/Chess-Challenge/discussions/3) - * Or with the Dockerfile provided (run: `./run.sh` (you need to have docker or podman installed on your machine)) +* [Running on Linux](https://github.com/SebLague/Chess-Challenge/discussions/3) Or with the Dockerfile provided (run: `./run.sh` (you need to have docker or podman installed on your machine)) * Issues with illegal moves or errors when making/undoing a move * Make sure that you are making and undoing moves in the correct order, and that you don't forget to undo a move when exiting early from a function for example. * How to tell what colour MyBot is playing