Skip to content
Permalink
Browse files

Add Makefile and Dockerfile for building the server

  • Loading branch information
borodust committed Apr 22, 2017
1 parent 687a95e commit 5311d42f6d80c75d7ca099500ac25090cf0b879c
@@ -1,4 +1,5 @@
'(:engine
(:systems (mortar-combat::mortar-combat)
:log-level :debug)
:server-address "borodust.org"
:assets "assets/")
@@ -2,7 +2,8 @@


(defclass game-client (connector) ()
(:default-initargs :host "localhost" :port 8222))
(:default-initargs :host (property :server-address "127.0.0.1")
:port (property :proxy-server-port 8222)))


(defun make-game-client ()
@@ -3,7 +3,8 @@

(defclass game-server (connector)
((players :initform (make-hash-table :test 'equal)))
(:default-initargs :host "localhost" :port 8222))
(:default-initargs :host (property :server-address "127.0.0.1")
:port (property :proxy-server-port 8222)))


(defun make-game-server ()
@@ -30,7 +30,9 @@
(defun connect (name)
(with-slots (remote-server identity) (mortar-combat)
(unless remote-server
(let ((server (make-instance 'connector :host "127.0.0.1" :port 8778)))
(let ((server (make-instance 'connector
:host (property :server-address "127.0.0.1")
:port (property :info-server-port 8778))))
(setf remote-server server)
(run (>> (identify server name)
(instantly (id)
@@ -0,0 +1,13 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get install -y \
libuv1


EXPOSE 8778 8222

WORKDIR /mortar-combat-proxy/

ADD * ./

ENTRYPOINT ["./server.bin"]
@@ -0,0 +1,52 @@
WORK_DIR="$(dir $(abspath $(lastword $(MAKEFILE_LIST))))"
BUILD_DIR=$(WORK_DIR)/build


MANIFEST_FILE=$(BUILD_DIR)/manifest



build: image_archive


prepare:
mkdir -p $(BUILD_DIR)/{server,}
cp $(WORK_DIR)/Dockerfile $(BUILD_DIR)/server/Dockerfile

manifest: prepare
sbcl --non-interactive \
--eval "(ql:write-asdf-manifest-file \"$(MANIFEST_FILE)\" :if-exists :supersede)"

executable: prepare manifest
buildapp --output $(BUILD_DIR)/server/server.bin \
--entry "mortar-combat.proxy::main" \
--manifest-file $(MANIFEST_FILE) \
--load-system "mortar-combat/proxy" \
--compress-core

image: executable
cd $(BUILD_DIR)/server/ && docker build -t mortar-combat/mortar-combat-proxy:latest .

image_archive: image
docker save mortar-combat/mortar-combat-proxy > $(BUILD_DIR)/mortar-combat-proxy.img
cd $(BUILD_DIR)/ && zip -r server.zip mortar-combat-proxy.img
rm -f $(BUILD_DIR)/mortar-combat-proxy.img


logs:
docker logs mortar-combat-proxy


container:
docker create --name mortar-combat-proxy -p 8778:8778 -p 8222:8222 \
mortar-combat/mortar-combat-proxy

serve:
docker start mortar-combat-proxy

stop:
docker stop mortar-combat-proxy


clean:
rm -rf $(BUILD_DIR)
@@ -3,8 +3,8 @@
(declaim (special *peer*))
(declaim (special *connection*))

(defvar *main-latch* (mt:make-latch))

(defvar *main-latch* (mt:make-latch))

(define-constant +server-version+ 1)
(define-constant +routing-buffer-size+ (* 64 1024))
@@ -97,8 +97,8 @@
:stream t)))
(in-new-thread "connector-thread"
(as:with-event-loop ()
(setf proxy-server (make-server "127.0.0.1" 8222)
info-server (make-server "127.0.0.1" 8778)))))))
(setf proxy-server (make-server "0.0.0.0" 8222)
info-server (make-server "0.0.0.0" 8778)))))))


(defmethod make-system-context ((this mortar-combat-proxy))

0 comments on commit 5311d42

Please sign in to comment.
You can’t perform that action at this time.