add files
This commit is contained in:
parent
631a97f2b8
commit
330874a4dc
54
Dockerfile
Normal file
54
Dockerfile
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
FROM alpine:latest AS builder
|
||||||
|
LABEL maintainer="tomasz@chorwat.pl"
|
||||||
|
LABEL project="https://github.com/tchorwat/stockfish"
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apk add --no-cache git g++ make
|
||||||
|
|
||||||
|
RUN git clone --depth 1 --branch sf_15 https://github.com/official-stockfish/Stockfish.git
|
||||||
|
|
||||||
|
WORKDIR /Stockfish/src
|
||||||
|
RUN echo "arch:$( uname -m )" \
|
||||||
|
&& case $( uname -m ) in \
|
||||||
|
x86_64) \
|
||||||
|
make build ARCH=x86-64-modern \
|
||||||
|
;; \
|
||||||
|
aarch64) \
|
||||||
|
make build ARCH=armv8 \
|
||||||
|
;; \
|
||||||
|
armv7l) \
|
||||||
|
make build ARCH=armv7 \
|
||||||
|
;; \
|
||||||
|
ppc64le) \
|
||||||
|
make build ARCH=ppc-64 \
|
||||||
|
;; \
|
||||||
|
*) \
|
||||||
|
exit 1 \
|
||||||
|
;; \
|
||||||
|
esac
|
||||||
|
|
||||||
|
RUN echo "Source used to build binaries from this directory could be find at: https://github.com/official-stockfish/Stockfish/tree/sf_15" > /Stockfish/source.txt
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
LABEL maintainer="tomasz@chorwat.pl"
|
||||||
|
LABEL project="https://github.com/tchorwat/stockfish"
|
||||||
|
|
||||||
|
COPY ./entrypoint.sh /
|
||||||
|
|
||||||
|
RUN chmod +x /entrypoint.sh \
|
||||||
|
&& apk add --no-cache libstdc++ ucspi-tcp6 \
|
||||||
|
&& addgroup -g 1000 stockfish \
|
||||||
|
&& adduser -u 1000 -G stockfish -HD stockfish
|
||||||
|
|
||||||
|
WORKDIR /stockfish/
|
||||||
|
USER stockfish:stockfish
|
||||||
|
|
||||||
|
COPY --chown=stockfish:stockfish --from=builder /Stockfish/src/stockfish /stockfish/
|
||||||
|
COPY --chown=stockfish:stockfish --from=builder /Stockfish/Copying.txt /stockfish/
|
||||||
|
COPY --chown=stockfish:stockfish --from=builder /Stockfish/source.txt /stockfish/
|
||||||
|
COPY --chown=stockfish:stockfish --from=builder /Stockfish/src/*.nnue /stockfish/
|
||||||
|
|
||||||
|
EXPOSE 23249
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
start:
|
||||||
|
docker run -d -p 23249:23249 -p 23250:23250 --name stockfish stockfish:15
|
||||||
|
@echo "Stockfish is running on port 23249"
|
||||||
|
@echo "Interact with it using the following command (you can substitute `netcat` for `telnet`):"
|
||||||
|
@echo "nc localhost 23249"
|
||||||
|
|
||||||
|
stop:
|
||||||
|
docker stop stockfish
|
||||||
|
docker rm stockfish
|
||||||
|
|
||||||
|
build: Dockerfile
|
||||||
|
docker build -t stockfish:15 .
|
||||||
|
|
||||||
|
run:
|
||||||
|
python app.py
|
16
app.py
Normal file
16
app.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# a chess playing application using pychess
|
||||||
|
# use the stockfish binary to play chess
|
||||||
|
|
||||||
|
import chess
|
||||||
|
import chess.engine
|
||||||
|
|
||||||
|
stockfish = chess.engine.SimpleEngine.popen_uci("./stockfish")
|
||||||
|
|
||||||
|
board = chess.Board()
|
||||||
|
|
||||||
|
while not board.is_game_over():
|
||||||
|
result = stockfish.play(board, chess.engine.Limit(time=0.1))
|
||||||
|
board.push(result.move)
|
||||||
|
print(board, "\n")
|
||||||
|
|
||||||
|
stockfish.quit()
|
9
entrypoint.sh
Executable file
9
entrypoint.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
tcpserver -c2 0 23249 /stockfish/stockfish
|
||||||
|
else
|
||||||
|
# else default to run whatever the user wanted like "bash" or "sh"
|
||||||
|
exec "$@"
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user