Skip to content

Commit 6085946

Browse files
Merge pull request #1 from X-R-G-B/main
Add Dockerfile + How to run it (linux only)
2 parents 73ade11 + a395508 commit 6085946

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM docker.io/archlinux:latest
2+
RUN pacman-key --init
3+
RUN pacman -Syu --noconfirm \
4+
dotnet-sdk-6.0 \
5+
mesa \
6+
&& pacman -Scc --noconfirm
7+
COPY . /app/
8+
WORKDIR /app/Chess-Challenge/
9+
RUN cd /app/ && dotnet build
10+
CMD dotnet run

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ All names (variables, functions, etc.) are counted as a single token, regardless
7070
* For example: `cd C:\Users\MyName\Desktop\Chess-Challenge\Chess-Challenge`
7171
* Now use the command: `dotnet run`
7272
* This should launch the project. If not, open an issue with any error messages and relevant info.
73-
* [Running on Linux](https://github.com/SebLague/Chess-Challenge/discussions/3)
73+
* [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))
7474
* Issues with illegal moves or errors when making/undoing a move
7575
* 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.
7676
* How to tell what colour MyBot is playing

run.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash -e
2+
3+
if grep -q 'Arch' /etc/os-release; then
4+
unset DBUS_SESSION_BUS_ADDRESS
5+
fi
6+
7+
if [ -z "$WAYLAND_DISPLAY" ]; then
8+
CRI_OPT+=(
9+
--network host
10+
-e XAUTHORITY=/app/.Xauthority
11+
-v "$XAUTHORITY:/app/.Xauthority:ro"
12+
)
13+
fi
14+
15+
CRI="$(command -v podman || command -v docker)"
16+
17+
if ! "${CRI[@]}" image ls &>/dev/null; then
18+
CRI=(sudo "${CRI[@]}")
19+
fi
20+
21+
"${CRI[@]}" build . -t chess
22+
23+
"${CRI[@]}" run --rm --name chess \
24+
"${CRI_OPT[@]}" \
25+
--device /dev/dri/ \
26+
-e DISPLAY \
27+
-e XDG_RUNTIME_DIR \
28+
-v /dev/shm/:/dev/shm/ \
29+
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
30+
-v "$XDG_RUNTIME_DIR:$XDG_RUNTIME_DIR" \
31+
chess

0 commit comments

Comments
 (0)