Running the CxReports Docker Application¶
This guide outlines the steps to run the CxReports Docker application, which has a dependency on a Postgres database, using Docker Compose.
Setup Video¶
Prerequisites¶
- Docker installed on your machine. Visit Docker's official installation guide for instructions.
- Basic knowledge of Docker commands.
Docker Compose Configuration¶
Prepared Configuration Files
Prepared configuration files are available on GitHub.
Create a new folder on your machine and save the docker-compose.yml
file in it.
Below is the file that defines the codaxy/cx-reports service and its database dependency:
services:
app:
image: codaxy/cx-reports:latest
depends_on:
- db
volumes:
- ./logs:/app/Logs
ports:
- "80:8080"
restart: always
secrets:
- source: appsett_app
target: /app/appsettings.Production.json
db:
image: postgres
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: cxreports # Replace with your database name
POSTGRES_USER: postgres # Replace with your database user
POSTGRES_PASSWORD: password # Replace with your database password
restart: always
secrets:
appsett_app:
file: ./appsettings.Production.json
volumes:
postgres_data:
CxReports runs internally on port 8080, so you need to map it to desired port on your machine. In the example above, we mapped it to port 80.
Application Configuration¶
- Create a new folder named
logs
in the same root directory. - Create a new file named
appsettings.Production.json
in the root directory as well with the following content to it:
{
"ConnectionStrings": {
"Database": "Host=db;Database=cxreports;Username=postgres;Password=password"
},
"Encryption": {
"Key": "6F761C152A69C34B655BFF6226116AD4",
"Vector": "A9B2BC02C2FDDE88"
},
"RootUser": {
"Email": "[email protected]",
"Password": "password",
"DisplayName": "First User"
}
}
RootUser is the first user that will be created in the system. You can change the email and password to your liking.
Encryption¶
You should replace the default encryption parameters to protect sensitive data stored in the database, i.e. license keys, database connection strings, etc.
To generate a new encryption key and vector, run the following bash command:
This command will generate 32 chars long key (key
) and vector (iv
). The vector should be 16 characters long, so use just the first 16 chars. Replace the values in the appsettings.Production.json
file with the values you get from the command.
Warning
Key is 32 chars long and vector should be 16 chars long, so use the first 16 chars of the newly generated vector (iv
).
Final directory structure should look like this:
- Run the following command in the same directory to start the application:
- Open your browser and navigate to
http://localhost:80
to access the application. - To stop the application, run the following command:
Path Base¶
Path Base is a feature that allows you to host the application under a subdirectory. For example, if you want to host the application under https://example.com/reports
, you need to set the PathBase
property in the appsettings.Production.json
file:
SMTP Configuration¶
To configure SMTP settings, edit the appsettings.Production.json
file and add the following section:
{
"SmtpServer": {
"From": "[email protected]",
"ReplyTo": "[email protected]",
"DisplayName": "Company Report",
"Host": "smtp.example.com",
"Port": 25,
"Username": "username",
"Password": "password",
"EnableSsl": true,
"DegreeOfParallelism": 4
}
}
DegreeOfParallelism
is the maximum number of concurrent emails that can be sent. If not specified, the default value is 1.