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.

voxobscuro
  • 2,132
  • 1
  • 21
  • 45
Werner
  • 139
  • 10

1 Answers1

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

voxobscuro
  • 2,132
  • 1
  • 21
  • 45
  • 1
    You can use `shards build test --poduction` without running `shards install` before :) – Faustino Aguilar Feb 22 '18 at 16:05
  • 1
    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. – isaacsloan Feb 26 '18 at 00:08
  • 1
    @NickM Yes, I believe the apache module `proxy` provides essentially the same thing as nginx proxy_pass. – voxobscuro Jun 28 '18 at 22:41