How to Deploy an Amber App on Ubuntu?
Asked Answered
C

1

6

Just discovered Amber...looks nice! How can I deploy a sample App on an Ubuntu Server? Should it be done just like Rails, routing the path to public? Or some other part of the structure?

Thanks for your advice.

Claudication answered 9/2, 2018 at 10:52 Comment(0)
C
8

Amber will serve the static assets for you, just point nginx at port 3000.

This is a good starting point for nginx configuration as a front to Amber running on port 3000:

upstream amber {
  server 127.0.0.1:3000;
}

server {
  listen 80 default_server;
  listen [::]:80 default_server;

  root /var/www/html;
  index index.html index.htm index.nginx-debian.html;

  server_name _;

  location / {
    proxy_pass http://amber;
  }
}

Then, start Amber with AMBER_ENV=production:

#!/bin/bash

set -euo pipefail
IFS=$'\n\t'

npm install 
npm run release 
shards build app --production

# if you need it
# export DATABASE_URL="postgres://user:password@hostname:port/database_name"
export AMBER_ENV="production"

exec bin/app

This all assumes your amber app is named app

Coheman answered 14/2, 2018 at 14:26 Comment(3)
You can use shards build test --poduction without running shards install before :)Sigridsigsmond
Yeah that's a good solution. Technically you could also deploy without nginx but that would require running Amber on port 80 or 443 which requires superuser access (usually not recommended) for web apps.Unfix
@NickM Yes, I believe the apache module proxy provides essentially the same thing as nginx proxy_pass.Coheman

© 2022 - 2024 — McMap. All rights reserved.