Closed ringabout closed 2 years ago
It would be helpful to cover the following deployment options in the docs for varying needs and preferences:
Adding my notes for my Prologue app setup as a systemd service below:
Use Nginx as a reverse proxy. This should improve security for the Prologue app, and Nginx can also be configured to serve the app's static files more efficiently.
For static file serving, I use Prologue's staticFileMiddleware in development mode:
In app.nim:
when not defined(release):
app.use(staticFileMiddleware(cfg.staticDir))
Added to nginx server configuration:
location ^~ /public {
try_files $uri $uri/ =404;
}
task release, "Build a production release":
--verbose
--forceBuild:on
--opt:speed
--define:release
--define:ssl
--define:usestd # stdlib asynchttpserver
--define:logueRouteLoose # optional loose routing
--hints:off
--outdir:"."
setCommand "c", "src/app.nim"
[Unit]
Description=prologue
After=network.target nginx.service
Wants=network-online.target
[Service]
Type=simple
User=<username>
WorkingDirectory=<path to app dir>
EnvironmentFile=/etc/default/prologue # optional define environment variables
ExecStart=/usr/bin/stdbuf -oL <path to app binary>
# Restart when crashes.
Restart=always
RestartSec=1
StandardOutput=syslog+console
StandardError=syslog+console
[Install]
WantedBy=multi-user.target
Create a deploy.sh
script that will build a production release binary and restart the prologue systemd service
nimble release
sudo systemctl restart prologue
sudo systemctl status prologue
The codebase for the above prologue app is now public at daehee/cvebase-nim.
I've started tackling this with a first draft of a guide via PR #167 . That one is already merged, but I still believe it could be improved upon. It's basically a guide for deploying using docker and nginx, containing a quick idea on how to configure nginx, how to write the write the dockerfile and prepare other buildfiles, how to create the image and then later on run the image on your server including various mounting points.
I think an okay next step would be to make a minimal project that would do exactly that and link to it in the deployment.md
Other than that, if there are any additions, corrections, improvements or rewrites anybody wants to make, feel free, I have no skin in this game, I just want there to be some deployment-guidance for prologue, I don't care if the words that describe it are mine or not.
Here is the documentation of deployment => https://planety.github.io/prologue/deployment
systemd