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

Remove Dependence On External Assets #24

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

asmr-hex
Copy link
Collaborator

@asmr-hex asmr-hex commented Aug 31, 2018

Overview

currently, xaqt relies on two external assets which must be accessed at runtime:

  1. data/compilers.json: read in to configure which compilers are available
  2. data/Payload: a directory which is moved into a mounted volume in the Docker container. this directory contains the scripts necessary for executing user code within the docker container.
    when the xaqt package is installed on the $GOPATH (e.g. from running go get github.com/frenata/xaqt) then the dependence on these external assets causes no problems since the path to these external assets is correctly maintained.

However, if the xaqt package is used as a library and is vendored, which is often the case with apps which require a stable deploy process, then the paths to these assets are no longer correctly maintained. This makes renders the library unusable in such situations.

The main problem that this PR addresses is the reliance of the library on external assets. This is achieved by hard-coding the compilers.json into a Compilers struct (naming it DEFAULT_COMPILERS since that is, in fact, what it is) and COPYing the data/Payload directory into the docker container at image build time rather than at runtime.

Major Changes

  • introduce DEFAULT_DOCKER_IMAGE constant
  • switch default docker image to connorwalsh/xaqt from frenata/xaqt-sandbox (this can be switched back once @frenata builds and pushes a new image)
  • rename data/Payload -> entrypoint
  • copy entrypoint directory into image in Dockerfile
  • rename ReadCompilersFromJSON() to GetCompilers()
  • refactor GetCompilers to be variadic s.t. if no args are provided it loads default compilers
  • change ExecutionDetails.Disabled from string -> bool (not entirely sure why it was of type string to begin with, maybe i missed something(?))
  • introduce ExportToJSON() method to Compilers type
  • remove data/DockerTimeout.sh and data/compilers.json since we don't need them anymore
  • update entrypoint/script.sh, entrypoint/mysql_runner.sh to work with modified directory structure.
  • remove CopyPayload() method in sandbox since we are no longer copying the data/Payload directory

Caveats in Refactor

since we still need to mount a volume to insert the user code into the container, but we can't mount into the entrypoint directory without overwriting the directory (and thus deleting all the run scripts), we must mount/load the usercode into a separate directory than the run scripts. this results in the follows directory structure:

/usercode/ # this is where the usercode is loaded into
/entrypoint/ # this is where the run scripts are stored

this means that the run scripts need to call the code from the correct directory.

this PR resolves issue #23 and issue #11

connorwalsh added 5 commits August 30, 2018 01:16
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

Successfully merging this pull request may close these issues.

None yet

3 participants