Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deployment #55

Closed
ringabout opened this issue Sep 17, 2020 · 4 comments
Closed

deployment #55

ringabout opened this issue Sep 17, 2020 · 4 comments

Comments

@ringabout
Copy link
Member

systemd

@daehee
Copy link

daehee commented Feb 8, 2021

It would be helpful to cover the following deployment options in the docs for varying needs and preferences:

  1. Heroku
  2. Dokku (self-hosted Heroku)
  3. systemd

Adding my notes for my Prologue app setup as a systemd service below:

Setup Nginx

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;
        }

Add nimble task

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"

Create systemd service

[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 script

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

@ringabout ringabout pinned this issue Feb 9, 2021
@daehee
Copy link

daehee commented Mar 21, 2022

The codebase for the above prologue app is now public at daehee/cvebase-nim.

@PhilippMDoerner
Copy link
Contributor

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.

@ringabout
Copy link
Member Author

Here is the documentation of deployment => https://planety.github.io/prologue/deployment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants