Step 1: Dockerfile Configuration
The deployment process begins by ensuring the Dockerfile
is correctly configured. The following Dockerfile
uses the .NET SDK 7.0 as the base image. Ensure that the required scripts and files are in place before proceeding.
FROM mcr.microsoft.com/dotnet/sdk:7.0
COPY . .
ENTRYPOINT [ "powershell.exe", "./Build.ps1" ]
This configuration copies the current directory content into the Docker image and sets PowerShell to execute the Build.ps1
script during the container startup.
Step 2: Build the Docker Image
Next, build the Docker image using the Docker CLI. Run the following command in the root of your project directory where the Dockerfile
is located:
docker build -t intellenum:production .
This command builds a Docker image tagged as intellenum:production
. Ensure that your terminal has access to Docker.
Step 3: Running the Docker Container
Once the image is built, you can run a container from this image in the production environment. Use the following command:
docker run -d -p 80:80 --name intellenum_production intellenum:production
In this command:
-d
runs the container in detached mode.-p 80:80
maps port 80 of the container to port 80 on the host machine.--name intellenum_production
gives a custom name to the running container.
Step 4: Testing the Deployment
After the container is up and running, it’s crucial to validate that the application is functioning as expected. You can test it by accessing the defined URL in your web browser or using a tool like curl
.
For example:
curl http://localhost
This should return the expected output from your deployed application.
Step 5: Running Tests
To ensure that everything is functioning correctly, you may want to run the tests provided within the application. Modify the Dockerfile
for running tests if necessary, and use the following command inside the Docker container:
dotnet test -c Release --filter * # Modify to `-p THOROUGH` for thorough testing.
The above command runs the tests in Release configuration. If you want to run thorough tests, pass the switch -p THOROUGH
to the dotnet test
command.
Step 6: Configure Environment Variables
If there are any environment variables necessary for the application’s functionality, you can pass them at runtime:
docker run -d -p 80:80 --name intellenum_production -e ASPNETCORE_ENVIRONMENT=Production intellenum:production
This example sets the ASPNETCORE_ENVIRONMENT
variable to Production
.
Cleanup
After testing or when a new version is to be deployed, stop and remove the container using:
docker stop intellenum_production
docker rm intellenum_production
If a new image version is deployed, consider removing the old images to free up space:
docker rmi intellenum:production
These steps encompass a standard process for deploying stevedunn/intellenum
in a production environment using Docker, ensuring a repeatable and efficient deployment.
Source:
- Dockerfile
- Tests and configurations mentioned in the sample references.