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 Dotfuscator 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 mcr.microsoft.com/dotnet/sdk:8.0 # Copy Dotfuscator to the image COPY PreEmptive.Protection.Dotfuscator.Pro.{X.Y.Z}.nupkg . # Install zip and extract Dotfuscator RUN apt-get update && \ apt-get install -y zip && \ mkdir -p /opt/local/PreEmptive.Protection.Dotfuscator.Pro && \ unzip PreEmptive.Protection.Dotfuscator.Pro.{X.Y.Z}.nupkg -d /opt/local/PreEmptive.Protection.Dotfuscator.Pro # Set up to run the command line interface ENTRYPOINT ["dotnet", "/opt/local/PreEmptive.Protection.Dotfuscator.Pro/tools/programdir/netcore/dotfuscator.dll"]
To build this image:
- Save your
Dockerfile
in the directory of your choice, and make sure you know where it is. - Download the
PreEmptive.Protection.Dotfuscator.Pro.{x.y.z}.nupkg
package from PreEmptive. - Place
PreEmptive.Protection.Dotfuscator.Pro.{x.y.z}.nupkg
in the same directory asDockerfile
(listed above). - Run
docker build -t preemptive/dotfuscator:{x.y.z} {path to the directory containing 'Dockerfile'}
.
Running the Dotfuscator container is simple; you must pass the license information. This can either be mirrored from the current environment:
docker run --rm -e DOTFUSCATOR_LICENSE -v {projectPath}:/code preemptive/dotfuscator:{x.y.z} /code/dotfuscatorconfig.xml
Set in the container’s environment:
docker run --rm -e DOTFUSCATOR_LICENSE={LicenseString} -v {projectPath}:/code preemptive/dotfuscaator:{x.y.z} /code/dotfuscatorconfig.xml
Or passed via the command line:
docker run --rm -v {projectPath}:/code preemptive/dotfuscator:{x.y.z} -license:<license-string> /code/dotfuscatorconfig.xml
Additional arguments can be found here.
Restricted or No Internet Troubleshoot
If your Docker has restricted/no internet access, here are two approaches on how to install the required tools.
Solution 1: Incorporating Tools into the Docker Build Context
This approach involves creating a Dockerfile with the necessary tools for .NET assembly processing and obfuscation. The tools (ILASM and ILDASM) are copied directly into the Docker image.
Below is the Dockerfile script for this method for reference:
#Create a directory for the tools inside the container RUN mkdir -p /usr/local/tools #Copy tools from the host to the container #Ensure ilasm and ildasm are placed within the build context of the Dockerfile COPY ilasm /usr/local/tools/ilasm COPY ildasm /usr/local/tools/ildasm #Make the tools executable RUN chmod +x /usr/local/tools/ilasm /usr/local/tools/ildasm #Set environment variables for Dotfuscator to locate the tools ENV ILASM_PATH=/usr/local/tools/ilasm ENV ILDASM_PATH=/usr/local/tools/ildasm #Copy Dotfuscator and its configuration into the container COPY /path/to/dotfuscator /usr/local/dotfuscator COPY /path/to/dotfuscatorconfig.xml /usr/local/dotfuscator/dotfuscatorconfig.xml #Define the default command to run Dotfuscator with the provided configuration #Adjust the command as needed to execute Dotfuscator #For example : CMD ["dotfuscator", "/usr/local/dotfuscator/dotfuscatorconfig.xml"]
Solution 2: Utilize Docker Volumes for External Tools
In this method, the tools are placed outside the Docker build context and mounted into the container at runtime. This allows for greater flexibility and avoids the need to copy tools into the Docker image during the build process.
The following Dockerfile and Docker run command are a reference to illustrate this approach:
Dockerfile:
#Create directories inside the container for tools and Dotfuscator RUN mkdir -p /usr/local/tools /usr/local/dotfuscator #Set environment variables for Dotfuscator to find the tools ENV ILASM_PATH=/usr/local/tools/ilasm ENV ILDASM_PATH=/usr/local/tools/ildasm ENV DOTFUSCATOR_PATH=/usr/local/dotfuscator #Copy Dotfuscator and its configuration file into the container COPY /path/to/dotfuscator /usr/local/dotfuscator COPY /path/to/dotfuscatorconfig.xml /usr/local/dotfuscator/dotfuscatorconfig.xml #Define the default command to run Dotfuscator with the provided configuration # For Example: CMD ["dotfuscator", "/usr/local/dotfuscator/dotfuscatorconfig.xml"]
Docker Run Command:
To run the Docker container and mount the tools from a specific location on your host machine:
Command for reference:
docker run -it --name dotnet-dotfuscator-container \ -v /path/on/host/ilasm:/usr/local/tools/ilasm \ -v /path/on/host/ildasm:/usr/local/tools/ildasm \ -v /path/on/host/ilasm:/usr/local/tools/ilasm: Mounts the ilasm tool from your host machine to the container. -v /path/on/host/ildasm:/usr/local/tools/ildasm: Mounts the ildasm tool from your host machine to the container.