Skip to content

Commit

Permalink
[cw|frenata#5] add docker-compose and .env files
Browse files Browse the repository at this point in the history
Major Changes:
* add docker-compose.yml for orchestrating building and running
  containers
* add .env file for setting environment variables inside docker
  containers

TODO:
* integrate test code to run on container startup
* create shared volumes for input/output between api server and
  compilebox
  • Loading branch information
connorwalsh committed Mar 10, 2018
1 parent bbdbb86 commit cecaf19
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# API server vars
COMPILEBOX_API_SERVER_PORT=31337
2 changes: 1 addition & 1 deletion API/src/compilebox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ExecutionResult struct {
var box sandbox.Interface

func main() {
port := getEnv("COMPILEBOX_PORT", "31337")
port := getEnv("COMPILEBOX_API_SERVER_PORT", "31337")

box = sandbox.New("data/compilers.json")

Expand Down
1 change: 1 addition & 0 deletions API/src/sandbox/docker_spawner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func DefaultSandboxOptions() SandboxOptions {
tmp = "/tmp"
}

// TODO (cw|3.9.18) get vm_name from environment variable in .env file
return SandboxOptions{tmp, pwd, "virtual_machine", time.Second * 5}
}

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ WORKDIR /bin/
# copy over single binary from build stage --^
COPY --from=server /go/bin/compilebox .

EXPOSE 6666
# copy compilers data
COPY ./API/data/compilers.json ./data/compilers.json

# run comilebox API server
CMD ["compilebox"]
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '2'
services:
compilebox_api_server:
build:
context: .
env_file: .env
volumes:
- /var/run/docker.sock:/var/run/docker.sock # use host Docker daemon
ports:
- "${COMPILEBOX_API_SERVER_PORT}:${COMPILEBOX_API_SERVER_PORT}"
depends_on:
- compilebox
compilebox:
env_file: .env
build:
context: ./Setup/
command: echo "compilebox build complete"

0 comments on commit cecaf19

Please sign in to comment.