Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running the service in a docker container #5

Open
frenata opened this issue Mar 8, 2018 · 8 comments
Open

Support running the service in a docker container #5

frenata opened this issue Mar 8, 2018 · 8 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@frenata
Copy link
Owner

frenata commented Mar 8, 2018

From #2 :

dockerize compilebox API server: right now, the compilebox API server doesn't run in docker, but it should be really easy to get that up and running. In my opinion this would dramatically increase the ease of use since,

  1. it would simplify the setup (just docker build and run the container; no build dependencies like gb etc.)
  2. it would simplify integration with other backend services using docker-compose
    But, you may ask-- "wait, doesn't compilebox spin up a docker container tho? Wouldn't that mean....a docker container....in a.... docker container????". While docker in docker is a thing (not recommended), luckily we can allow docker containers to spin up sibling containers by making compilebox use the docker daemon of the host. See this blog post for more details. I've actually already started working on this in a fork so I'll probably be submitting a PR at some point.
@frenata frenata added the enhancement New feature or request label Mar 8, 2018
@asmr-hex asmr-hex self-assigned this Mar 9, 2018
@asmr-hex
Copy link
Collaborator

asmr-hex commented Mar 9, 2018

Overview

The idea is that, when running a compilebox API server, we only need to run build.sh which will handle building the actual compilebox Docker image and the API server image. Systems which will interact with the API server should be able to integrate both Dockerfiles into their deployment setup (e.g. docker-compose.yml).

Proposed Changes

  • build.sh: will build the compilebox docker image on the host and then build the compilebox API server using the Dockerfile (below).
  • Dockerfile: will build the docker image for the compilebox API server

Usage

normally we can just run docker run on our API server image, but since the running container will be using Docker, we want to make it use the Docker daemon on the host. We can do this by running,

λ docker run -v /var/run/docker.sock:/var/run/docker.sock -d --name server_container server_image

which links the docker daemon socket in the container with the one on the host. This allows the host to spin up a sibling container.

Note that we can also specify this runtime argument within docker-compose.yml.

Questions

  • Docker volume in Dockerfile vs. docker-compose.yml for allowing container to use host Docker daemon? : VOLUME in Dockerfile specifies a point within the container to be mounted at build time whereas, the -volumes properties in docker-compose.yml specifies where to mount a volume on the host machine. Important to note that the -volumes property in docker-compose.yml is passed to docker run at runtime. Also, we are allowed to use -volumes without specifying a VOLUME in the Dockerfile.
  • run a bash script instead of a Dockerfile in docker-compose.yml build?: doesn't look like this is possible, so build.sh will just be a convenience script for building both Dockerfiles at the same time, but if a system is using docker-compose, the docker-compose.yml can just build each of the two Dockerfiles without using the build.sh.
  • persist compilebox Docker image inside container spinning it up as a sibling container or on host?

asmr-hex pushed a commit to asmr-hex/compilebox that referenced this issue Mar 10, 2018
Major Changes:
* add Dockerfile for building API server image

TODO:
* add docker-compose.yml template to project root
* add build.sh script for buliding both docker images in repo
* add (possibly) a run.sh script for running both images
* add test for ensuring docker build/run works
* exec (eventually) test code in API server on container start
asmr-hex pushed a commit to asmr-hex/compilebox that referenced this issue Mar 10, 2018
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
asmr-hex pushed a commit to asmr-hex/compilebox that referenced this issue Mar 10, 2018
Major Changes:
* rename dockerfiles
* adjust docker-compose
* adjust Dockerfile-server
@frenata frenata added this to the 0.1.0 milestone Mar 13, 2018
asmr-hex pushed a commit to asmr-hex/compilebox that referenced this issue Mar 14, 2018
…ed vol

Major Changes:
* move langtest code into a smoke test in compilebox main.go
* begin setting up shared volumes between server api and compilebox

TODO:
* doesn't run yet, need to figure out shared volumes
* delete langtest cmd
@frenata
Copy link
Owner Author

frenata commented Mar 24, 2018

Possibly relevant to your work: since the actual sandbox is unlikely to change much, I've pushed it to docker hub https://hub.docker.com/r/frenata/xaqt/ (also experimenting with the proposed name).

We'll presumably still want the Dockerfile in the repo somewhere so that we can change it, but it could be moved out of the base directory. And presumably when you compose the images, you can pull it directly.

@frenata
Copy link
Owner Author

frenata commented Mar 25, 2018

I changed it so that https://hub.docker.com/r/frenata/xaqt-sandbox/ is set as the sandbox itself, so that we can use frenata/xaqt as the service target.

Once this is issue is resolved I'll make the appropriate changes to auto-build that target too.

@frenata
Copy link
Owner Author

frenata commented Apr 5, 2018

FYI @ConnorWalsh , I had to do some major surgery on the Dockerfile since it suddenly stopped building. Security certs for the version of node being built got deprecated apparently.

@asmr-hex
Copy link
Collaborator

@frenata, no worries! sorry for radio silence-- i'm getting back on this probably tomorrow

1 similar comment
@asmr-hex
Copy link
Collaborator

@frenata, no worries! sorry for radio silence-- i'm getting back on this probably tomorrow

@frenata
Copy link
Owner Author

frenata commented Apr 27, 2018

It's cool @ConnorWalsh , I haven't exactly been spending a lot of time on this lately either. Hoping to get back to a bit soon though.

@asmr-hex
Copy link
Collaborator

@frenata i was working on this previously but i am going to switch gears and refactor the library to use the Go Docker API since i think that is more valuable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants