Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Deploying applications across different environments often leads to compatibility headaches. An app might run perfectly on a developer's machine but encounter issues in testing or production because of differences in operating systems, dependencies, or configurations. Docker solves this problem by packaging applications into self-contained units that include everything needed to run the app, ensuring it works consistently everywhere, from development to production.
Docker Compose brings powerful benefits to containerized applications, especially with its use of environment variables to simplify configuration across different setups. By allowing key settings to be managed outside the code, Docker Compose makes deploying complex applications more straightforward and secure. Building on these benefits, this article will also show how you can use IronSecureDoc for secure document processing, tapping into Docker Compose’s flexibility to handle configurations for encryption and redaction efficiently.
Docker is an open-source system to ease application development, deployment, and running in a system through containerization. Containers are ultra-lightweight portable units that contain both an application and its dependencies so that they run uniformly everywhere-from the developer's machine to production servers. Containers share the kernel of the host's operating system compared to traditional virtual machines and, therefore, are much faster and more effective.
This would mean a virtualized template in the form of Docker images to make and maintain this set of containers. Furthermore, the platform contains Docker Hub, which is in a way a container image repository. The beauty of this technology lies in its ease of use concerning scalability, portability, and efficiency, which is one reason it has gained such popularity among many DevOps and cloud-based development workflows.
In Docker, an environment variable in the form of a key-value pair is used to configure settings in the containerized application. Such variables can be useful to control the behavior of the application itself without modifying its code, since easily, configurations such as database credentials and API keys or environment modes (for example: development, production) may be changed.
In Docker, an environment attribute can be defined inside the Dockerfile, inside the docker-compose.yml file, or passed at runtime using the docker run command. With the use of environment variables, Docker allows consistent and flexible application deployment across different environments and manages sensitive data like passwords and API tokens more effectively.
We can define environment variables in Docker in quite a few ways. They can be defined with a Docker Compose file, the docker-compose.yml file, in an environment file, or even at runtime, as you are executing the docker run command. Remember, keeping environment variables separate from the main configuration file leads to easier organization of variables! Here is a list of the various methods that can be applied to define your variables.
We can define environment variables directly in the Docker file, using the ENV instruction. That can be helpful if you want to include default values for the variables within your Docker image.
# Dockerfile
ENV APP_ENV=devepolment
ENV DATABASE_URL=postgres://user:password@db:1234/mydev
# Dockerfile
ENV APP_ENV=devepolment
ENV DATABASE_URL=postgres://user:password@db:1234/mydev
#Dockerfile
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'ENV APP_ENV=devepolment ENV DATABASE_URL=postgres: 'user:password@db:1234/mydev
The setting of environment variables with the values defined in the Docker file will automatically lead to the runtime of the container.
We can define environment variables for each service inside a docker-compose.yml with the help of the environment keyword. This is handy when you are using Docker Compose to manage a couple of services.
version: '3.8'
services:
myapp:
image: myapp:latest
environment:
- APP_ENV=development
- DATABASE_URL=postgres://user:password@db:1234/mydev
version: '3.8'
services:
myapp:
image: myapp:latest
environment:
- APP_ENV=development
- DATABASE_URL=postgres://user:password@db:1234/mydev
version:
'INSTANT VB TODO TASK: The following line uses invalid syntax:
''3.8' services: myapp: image: myapp:latest environment: - APP_ENV=development - DATABASE_URL=postgres: 'user:password@db:1234/mydev
We can specify environment variables when running a container by using the -e flag along with the docker run command. This is good for transient and dynamic values, which you probably wouldn't add to the Docker file.
docker run -e APP_ENV=development -e DATABASE_URL=postgres://user:password@db:1234/mydev:latest
docker run -e APP_ENV=development -e DATABASE_URL=postgres://user:password@db:1234/mydev:latest
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'docker run -e APP_ENV=development -e DATABASE_URL=postgres: 'user:password@db:1234/mydev:latest
We can store environment variables in a file like `.env` and load them into your Docker containers. In Docker Compose, we will refer to it with the env file directive.
APP_ENV=production
DATABASE_URL=postgres://user:password@db:1234/mydev
APP_ENV=production
DATABASE_URL=postgres://user:password@db:1234/mydev
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'APP_ENV=production DATABASE_URL=postgres: 'user:password@db:1234/mydev
We can manage multiple files, with environment variables outside the configuration files through the help of an env files.
IronSecureDoc for Docker allows developers to easily add a secure document processing capability to their containerized applications. Finally having learned Docker, you are enabled to encapsulate your ASP.NET Core application with IronSecureDoc in a homogenous environment that makes it easier to deploy and scale. To do this, you'll build a Dockerfile that orchestrates the construction of your ASP.NET Core application using the IronSecureDoc library and possibly other installation scripts or configurations needed to get things working.
Besides, it includes a docker-compose.yml file declaring the service dependencies and environment variables and mapped ports to get on. This makes performing document security tasks much more accessible so your application can run efficiently and effectively in an environment other than the one used during development or production. Installation and Configuration of IronSecureDoc Like in the case of Docker, proper installation and configuration of IronSecureDoc will be needed to properly realize its capabilities: document encryption, redaction, etc.
IronSecureDoc offers a range of powerful features for PDF security and document management:
These features make IronSecureDoc an excellent choice for sectors handling sensitive documents, such as legal, healthcare, and finance.
To install IronSecureDoc run the below command in a terminal window or Command Prompt to get the IronSecureDoc Docker image from the repository.
docker pull ironsoftwareofficial/ironsecuredoc
docker pull ironsoftwareofficial/ironsecuredoc
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'docker pull ironsoftwareofficial/ironsecuredoc
Once the IronSecureDoc image has been pulled. we can use the below docker-compose command to run the image into the docker container.
docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
We use the docker container to run IronSoftware's official repository. The command line shown above breaks into several parts which are explained below.
IronSecureDoc's REST API lets users redact, certify, and encrypt documents after it is launched in Docker; this feature is also mentioned elsewhere. Here's a link to the API endpoints and documentation with Swagger UI, once you have launched IronSecureDoc in a Docker container: http://localhost:8080/swagger/index.html.
From the above instance, we can send a POST request to the IronSecureDoc API to submit a document for encryption:
curl -X 'POST' \
'http://localhost:8080/v1/document-services/pdfs/encrypt?user_password=demo' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'pdf_file=@test.pdf;type=application/pdf'
curl -X 'POST' \
'http://localhost:8080/v1/document-services/pdfs/encrypt?user_password=demo' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'pdf_file=@test.pdf;type=application/pdf'
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'curl -X 'POST' \ 'http: -H 'accept: */ *' \ -H 'Content-Type: multipart/form-data' \ -F 'pdf_file=@test.pdf;type=application/pdf'
By doing this, IronSecureDoc will get the document and properly encrypt it.
In sum, Docker Compose's environment variables allow the configuration of applications in a very flexible and efficient way since the configuration details automatically separate from the application code. Consequently, managing different environments such as development, testing, and production is simpler, as only variables such as API keys, database credentials, and settings of an application need to be changed instead of its code.
Using Docker Compose to implement IronSecureDoc utilizes environment variables for securely handling the licensing information, for instance, the IronSecureDoc_LicenseKey, and also in specifying the HTTP ports or the environment mode preferred as either development or production using environment variables. Using environment variables for setup makes it simpler to deploy IronSecureDoc with much less cluttered and hard-to-scale configurations and boosts security.
Advanced features become accessible through a valid license of IronSecureDoc. The application of the tool is strictly dependent on certain terms of use. Though you can also utilize other high-performance libraries that IronSoftware offers to make the development process easier and faster, providing robust functionalities in working with PDFs, text recognition, and barcodes for any conceivable application.
9 .NET API products for your office documents