Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile + How to run it (linux only) #1

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +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)
* [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
Expand Down
31 changes: 31 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -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