/** * Executes a Docker environment. * * This class has a single method, `execute`, which starts a container from an * image and runs the command specified in the Dockerfile `CMD` instruction. * * It mounts the project's directory into the container a `/work` and uses it * as the working directory. * * It also sets the current user and group as the * user and group in the container. This means that within the container the * command that runs has the same permissions as the current user does in the * `/work` directory. * * Finally, it removes the container (but not the image). * * This then is the equivalent of running the container with Docker from within * the project directory using, * * docker run --rm --volume $(pwd):/work --workdir=/work --user=$(id -u):$(id -g) */ export default class DockerExecutor { /** * Run a Docker container * * @param name Name of the Docker image to use * @param folder Path of the project folder which will be mounted into the image */ execute(name: string, folder: string, command?: string): Promise; }