currently, xaqt relies on two external assets which must be accessed at runtime:
data/compilers.json: read in to configure which compilers are available
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.
Overview
currently,
xaqt
relies on two external assets which must be accessed at runtime:xaqt
package is installed on the$GOPATH
(e.g. from runninggo 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 aCompilers
struct (naming itDEFAULT_COMPILERS
since that is, in fact, what it is) andCOPY
ing thedata/Payload
directory into the docker container at image build time rather than at runtime.Major Changes
DEFAULT_DOCKER_IMAGE
constantconnorwalsh/xaqt
fromfrenata/xaqt-sandbox
(this can be switched back once @frenata builds and pushes a new image)data/Payload
->entrypoint
entrypoint
directory into image in DockerfileReadCompilersFromJSON()
toGetCompilers()
GetCompilers
to be variadic s.t. if no args are provided it loads default compilersExecutionDetails.Disabled
fromstring
->bool
(not entirely sure why it was of typestring
to begin with, maybe i missed something(?))ExportToJSON()
method toCompilers
typedata/DockerTimeout.sh
anddata/compilers.json
since we don't need them anymoreentrypoint/script.sh
,entrypoint/mysql_runner.sh
to work with modified directory structure.CopyPayload()
method insandbox
since we are no longer copying thedata/Payload
directoryCaveats 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:this means that the run scripts need to call the code from the correct directory.
this PR resolves issue #23 and issue #11