Prerequisites
Ensure you have the following tools and frameworks installed on your system:
- .NET Core SDK
- Required environment variables set for production configuration
- CI/CD pipeline setup (if applicable)
Step 1: Build the Application
First, navigate to the project directory in your terminal. Execute the build command to compile the application:
dotnet build
Ensure that there are no compilation errors before proceeding.
Step 2: Publish the Application
Use the publish command to create a self-contained deployment of the application. Specify the target runtime environment. For example, to target Windows x64:
dotnet publish -c Release -r win-x64 --self-contained
This command will generate the publish output in the bin/Release/netcoreappX.X/publish/
directory.
Step 3: Prepare Configuration
Ensure that your production configuration settings are correctly specified in appsettings.Production.json
. This includes connection strings, logging settings, and any environment-specific settings.
Example appsettings.Production.json
:
{
"ConnectionStrings": {
"DefaultConnection": "Server=prod-server;Database=prod-db;User Id=db-user;Password=db-password;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning"
}
}
}
Step 4: Deploy the Application
Copy the contents of the publish
directory to your production server. This can be done using various methods such as FTP, SSH, or cloud service deployment tools.
If using SSH, you might employ a command like:
scp -r bin/Release/netcoreappX.X/publish/ user@yourproductionserver:/var/www/oglr
Step 5: Configure Web Server
Set up your web server to host the application. For Nginx, create a configuration file under /etc/nginx/sites-available/oglr
:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Link the configuration:
sudo ln -s /etc/nginx/sites-available/oglr /etc/nginx/sites-enabled/
Test and restart Nginx:
sudo nginx -t
sudo systemctl restart nginx
Step 6: Start the Application
Navigate to the deployed directory on your server and start the application using dotnet
:
dotnet Oglr.dll
For convenience and to ensure the application runs in the background, consider using a process manager like systemd
.
Create a service file in /etc/systemd/system/oglr.service
:
[Unit]
Description=Oglr Service
After=network.target
[Service]
ExecStart=/usr/bin/dotnet /var/www/oglr/Oglr.dll
WorkingDirectory=/var/www/oglr
Restart=always
RestartSec=10
SyslogIdentifier=oglr
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl enable oglr
sudo systemctl start oglr
Step 7: Verify Deployment
After completing the deployment, verify that the application is running and accessible via your web browser by navigating to http://yourdomain.com
. Check logs for any errors if needed:
sudo journalctl -u oglr -f
By following these steps, the stevedunn/oglr application can be effectively deployed in a production environment, ensuring the necessary configurations and environment settings are in place for optimal performance.
Source: stevedunn/oglr documentation.