Serinus on your server
If you want to run Serinus on your server without the need for a service like Globe, you can do so by following these steps.
Getting Started
To run your application on your server there are more ways to do it. You can see the possibilities listed below.
- Run the Docker container on your server.
- Compile your application to a standalone executable and run it on your server.
- Run your application using the Dart SDK on your server like you would on your local machine.
Running the Docker container
To run your application in a Docker container, you will need to have Docker installed on your server. If you don't have Docker installed, you can follow the instructions on the Docker website.
You will also need Nginx or another web server to serve your application. You can install Nginx by running the following command:
sudo apt-get install nginxTo create a Dockerfile for your project, run the following command:
serinus deployYou can now build the image and run the container on your server.
docker build -t myapp .
docker run -d -p 8080:8080 myappConfigure Nginx
To configure Nginx to serve your application, create a new configuration file in the /etc/nginx/sites-available directory.
server {
server_name your_domain;
location / {
proxy_pass http://localhost:8080/;
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;
}
}
server {
listen 80;
server_name your_domain;
return 404; # managed by Certbot
}Enable the configuration file by creating a symbolic link in the /etc/nginx/sites-enabled directory.
sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/Reload Nginx to apply the changes.
sudo systemctl reload nginxYou can now access your application by visiting your domain in a web browser.
Compiling to a standalone executable
To compile your application to a standalone executable, you can use the dart compile exe command.
dart compile exe bin/entrypoint.dartThis will create an executable file in the bin directory that you can run on your server.
./bin/entrypointRunning with the Dart SDK
To run your application using the Dart SDK on your server, you can use the dart run command.
dart run bin/entrypoint.dartThis will start your application on your server.
Conclusion
You now have multiple ways to run your Serinus application on your server. Choose the method that best fits your needs and get your application up and running on your server.
More Information
To create this guide we used the following resources:
