diff --git a/.gitignore b/.gitignore index 01cd5b0..49a5689 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ octgn-data images *.exe -static \ No newline at end of file +static +.vagrant +ubuntu*.log +.vscode +rdb-data diff --git a/.vagrantplugins b/.vagrantplugins new file mode 100644 index 0000000..d11653b --- /dev/null +++ b/.vagrantplugins @@ -0,0 +1,26 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +class BuildCmd < Vagrant.plugin(2, :command) + def self.synopsis + "builds project on guest machine" + end + + def execute + with_target_vms(nil, single_target: true) do |vm| + vm.action(:ssh_run, ssh_run_command: "cd /vagrant; docker-compose up -d --force-recreate") + end + end +end + +class BuildProject < Vagrant.plugin(2) + name "Project builder" + + command "build" do + BuildCmd + end + + command "make-builder" do + MakeBuilder + end +end diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..4d53fc0 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,15 @@ +# Global rules +* { + tls off # Assume reverse proxy with TLS + gzip + root /static + proxy /api apigateway:80 { + transparent + without /api + websocket + } + cors /api { + allow_credentials true + allowed_headers Content-Type,Authorization + } +} diff --git a/Dockerfile.publish b/Dockerfile.publish new file mode 100644 index 0000000..323fe1f --- /dev/null +++ b/Dockerfile.publish @@ -0,0 +1,22 @@ +FROM golang:alpine AS builder + +ARG MODULE_PATH + +ENV GOPROXY https://modules.fromouter.space +ENV GO111MODULE=on + +WORKDIR /app + +# Get updated modules +COPY ./ ./ +RUN go mod download + +# Compile code +RUN CGO_ENABLED=0 go build -o /svc ./$MODULE_PATH + +FROM scratch AS final + +# Import the compiled executable from the first stage. +COPY --from=builder /svc /svc + +CMD [ "/svc" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..0dca1d0 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Server tools + +Tools and services needed for the MCG backend to work. + +### draftbot + +Bot for drafting MLP:CCG sets and cubes on MCG + +### buildmap / convertsets / genpics + +Tools for converting data/image packs from OCTGN to MCG/Cardgage + +### webclient + +Client for connecting to a Cardgage server and creating/joining test rooms diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..ff8a6a5 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,13 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.provider "virtualbox" do |v| + v.memory = 2048 + end + + config.vm.box = "ubuntu/cosmic64" + config.vm.network "private_network", ip: "192.168.22.23" + config.vm.provision "docker" + config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml", rebuild: true, run: "always" +end diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3c85942 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,84 @@ +version: "3" + +services: + consul: + container_name: consul + image: consul:latest + command: consul agent -dev -log-level=warn -ui -client=0.0.0.0 + hostname: consul + ports: + - "8500:8500" + networks: + - svc + + caddy: + container_name: caddy + image: abiosoft/caddy + volumes: + - ./Caddyfile:/etc/Caddyfile + - ./images:/images + ports: + - "80:2015" + networks: + - svc + + rdb: + container_name: rdb + image: rethinkdb:latest + volumes: + - rdb-data:/data + ports: + - "8000:8080" + networks: + - rdb + + redis: + container_name: redis + image: redis:alpine + networks: + - redis + + apigateway: + container_name: apigateway + image: moaorg/apigateway + depends_on: + - consul + networks: + - svc + + lobbysvc: + container_name: lobbysvc + image: moaorg/cardgage-lobby + environment: + - "JWT_KEY=this-is-a-test-key" + - "WSS_HOST=ws://192.168.22.23/api/room" + volumes: + - ".:/app" + depends_on: + - consul + - redis + networks: + - svc + - redis + + roomsvc: + container_name: roomsvc + image: moaorg/cardgage-room + environment: + - "JWT_KEY=this-is-a-test-key" + volumes: + - ".:/app" + depends_on: + - consul + - rdb + networks: + - svc + - rdb + +volumes: + rdb-data: + +networks: + svc: + rdb: + redis: