Browse Source

finish Dockerfile

master
Gabriel Pariat 2 years ago
parent
commit
b30e1961b5
  1. 26
      Dockerfile
  2. 2
      client/src/online-game.lisp
  3. 2
      server/server.asd
  4. 3
      server/src/server.lisp

26
Dockerfile

@ -0,0 +1,26 @@
FROM debian:bookworm
ENV buildpkgs "curl sbcl"
ENV qlurl https://beta.quicklisp.org/quicklisp.lisp
WORKDIR /usr/src/pariatech-pong/
COPY init.lisp .
COPY game ./game
COPY server ./server
RUN apt update && \
apt install -y ${buildpkgs} && \
apt auto-remove -y && \
curl -SOL ${qlurl} && \
sbcl --load quicklisp.lisp \
--eval "(quicklisp-quickstart:install)" \
--eval "(sb-ext:quit)"
EXPOSE 54321/tcp
CMD sbcl --load ~/quicklisp/setup.lisp \
--eval "(load \"game/game.asd\")" \
--eval "(load \"server/server.asd\")" \
--eval "(ql:quickload \"server\")" \
--eval "(in-package :pong.server)" \
--eval "(main)"

2
client/src/online-game.lisp

@ -52,7 +52,7 @@
`(start-online-game% (make-instance 'online-game ,@args))) `(start-online-game% (make-instance 'online-game ,@args)))
(defun open-socket () (defun open-socket ()
(setf *socket* (usocket:socket-connect "127.0.0.1" 54321 :element-type 'unsigned-byte)) (setf *socket* (usocket:socket-connect "pariatech.com" 54321 :element-type 'unsigned-byte))
(setf *stream* (usocket:socket-stream *socket*))) (setf *stream* (usocket:socket-stream *socket*)))
(defun write-to-server (data) (defun write-to-server (data)

2
server/server.asd

@ -8,7 +8,7 @@
:serial t :serial t
:depends-on ("game" "usocket" "bordeaux-threads") :depends-on ("game" "usocket" "bordeaux-threads")
:build-operation "program-op" :build-operation "program-op"
:build-pathname "../../AppDir/usr/bin/server" :build-pathname "../../bin/server"
:entry-point "pong.server:main" :entry-point "pong.server:main"
:pathname "src" :pathname "src"
:components :components

3
server/src/server.lisp

@ -67,7 +67,7 @@
(handle-message action stream client))) (handle-message action stream client)))
(defun open-server-socket (port) (defun open-server-socket (port)
(usocket:socket-listen "127.0.0.1" port :reuse-address t :element-type 'unsigned-byte)) (usocket:socket-listen "0.0.0.0" port :reuse-address t :element-type 'unsigned-byte))
(defun wait-for-sockets-ready (connections) (defun wait-for-sockets-ready (connections)
(usocket:wait-for-input connections :ready-only t :timeout 5)) (usocket:wait-for-input connections :ready-only t :timeout 5))
@ -185,6 +185,7 @@
;; (stop-server) ;; (stop-server)
(defun main () (defun main ()
(format t "Starting server!~%")
(unwind-protect (start-server 54321) (unwind-protect (start-server 54321)
(stop-server))) (stop-server)))

Loading…
Cancel
Save