rgreen312 / OwlPlace

https://rgreen312.github.io/OwlPlace/
5 stars 1 forks source link

backend: add dockerfile and refactor for build & test #26

Closed gvacaliuc closed 5 years ago

gvacaliuc commented 5 years ago

This patch adds a Dockerfile for building and running our backend application. Additionally, it refactors our command line flags so that we specify a set of cluster members when starting our backend service. In the future, this will likely be handled by a service discovery server, which will be able to more appropriately accommodate scenarios in which a cluster member fails and re-joins.

changes to command line interface

To start a cluster member, first define a cluster configuration file:

[
   "1": {
       "hostname": "backend1",
       "api_port": 3000,
       "consensus_port": 63000
   }
   ...
]

where the keys of the JSON object are the node IDs of the cluster members.

When starting a service, specify the path to that file as well as the node id of the server we're starting like so:

./server -config foo.json -nodeid 1

building

The Dockerfile (Dockerfile.server) leverages a multi-stage builder pattern that builds our deps, our service, and then copies our final binaries into a runtime image. To build (from the main folder), run:

docker build . -f Dockerfile.server -t owlplace

running

At this point, we have an image that will run our service packaged with its dependencies. To run several of them at one time, we'll use docker compose to define a few services. See docker-compose.yml for an example, and run docker-compose up to start 3 services.

gvacaliuc commented 5 years ago

fixing merge conflicts

gvacaliuc commented 5 years ago

@rgreen312 requested documentation to run this in the backend README file