PreEmptive does not provide pre-built Docker containers for our products, but it is a straightforward process to create your own containers with the distributions we provide. Keep in mind that you must use a Floating License for these containers.
Below is a sample Dockerfile for JSDefender as a starting point for building your containers. You will need to replace {x.y[.z]} with the appropriate major.minor[.patch] version.
Dockerfile:
FROM node:12.16.1 # Copy and install JSDefender COPY preemptive-jsdefender-*-{x.y.z}.tgz ./ RUN npm install -g preemptive-jsdefender-*-{x.y.z}.tgz --save-dev # Set up to run the command line interface ENTRYPOINT ["jsdefender"]
To build this image:
- Save your
Dockerfile
in the directory of your choice, and make sure you know where it is. - Download the JSDefender packages (e.g.
preemptive-jsdefender-core-{x.y.z}.tgz
,preemptive-jsdefender-cli-{x.y.z}.tgz
, etc.) from PreEmptive.
NOTE: If you have already installed or dockerized JSDefender Core, it is not necessary to add it again
- Place them in the same directory as
Dockerfile
(listed above). - Run
docker build -t preemptive/jsdefender:{x.y.z} {path to the directory containing 'Dockerfile'}
.
Running the JSDefender container is simple; you must pass the license information. This can either be mirrored from the current environment:
docker run --rm -e JSDEFENDER_LICENSE -v {projectPath}:/code preemptive/jsdefender:{x.y.z} /code/jsdefender.config.json
Set in the container’s environment:
docker run --rm -e JSDEFENDER_LICENSE={LicenseString} -v {projectPath}:/code preemptive/jsdefender:{x.y.z} /code/jsdefender.config.json
Or passed via the command line:
docker run --rm -v {projectPath}:/code preemptive/jsdefender:{x.y.z} -license:<license-string> /code/jsdefender.config.json
Additional arguments can be found here.