Docker image for running the correctomatic API. The source code for the correctomatic API is in the correction-api repository.
The image is available in Docker Hub.
There are two ways of configuring the image: with environment variables or with an .env file. In both cases, the variables are the same as defined in the correction-API's .env-example file.
You can use a .env file to configure the container. Mount the file to the container in the /app directory:
docker run --rm \
-v /path/to/.env:/app/.env \
correctomatic/apiThe documentation for shuch .env file is in the correction-API repository, but are the same as the environment variables described below.
The main variables you can pass are:
UPLOAD_DIRECTORY: Directory where the uploaded files will be stored. The path is from the container's point of view. You will probably need to share this directory with the correctomatic's runner processes, using a bind mount or a volume.PORT: Port where the API will listen. Defaults to 3000.REDIS_HOST: Host of the redis server, from the container's point of view.REDIS_PORT: Port of the redis serverREDIS_PASSWORD: Password for the redis serverDB_USER,DB_PASSWORD: Database credentialsDB_HOST,DB_PORT: Database connection parameters. The host is from the container's point of view.DB_NAME: Name of the database to use, defaults tocorrectomatic.JWT_SECRET_KEY: Key for the JWT tokens.
There are also variables for debugging:
NODE_ENV: Environment where the application is running. It can bedevelopment,testorproduction.LOG_LEVEL: Log level for the application.LOG_FILE: File where the logs will be written. The path is from the container's point of view.
You have the default values in the Dockerfile.
This is an example of how to run the container to connect to a remote docker server. You will need to mount the certificates in the container, and set the DOCKER_OPTIONS environment variable:
docker run --rm \
-e UPLOAD_DIRECTORY=\tmp\exercises \
-e REDIS_HOST=redis \
-e REDIS_PORT=6379 \
-e REDIS_PASSWORD=<value> \
-e DB_USER=<value> \
-e DB_PASSWORD=<value> \
-e DB_HOST=postgres \
-e DB_PORT=5432 \
-e NODE_ENV=development \
-e LOG_LEVEL=info \
-e LOG_FILE=/var/log/correctomatic/correctomatic.log \
-p 8080:8080 \
correctomatic/apiYou will probably need to include the redis and postgresql hosts and to mount the upload directory:
docker run ...
...
--add-host=redis:host-gateway \
--add-host=postgresql:host-gateway \
--mount type=bind,source=/tmp/exercises,target=/tmp/exercises \
correctomatic/apiBuild the image with ./build.sh. All the parameters passed to the script will be passed to the docker build command. For example, to build the image with a custom tag:
./build.sh --no-cache --tag correctomatic/api:custom-tagTake in account that some parameters are fixed in the script, like the git repository and the node version to install in the image, which are defined in the .env file in this repository.