【问题标题】:How to Deploy an Amber App on Ubuntu?如何在 Ubuntu 上部署 Amber 应用程序?
【发布时间】:2018-07-20 03:07:32
【问题描述】:

刚刚发现 Amber...看起来不错!如何在 Ubuntu 服务器上部署示例应用程序?是否应该像 Rails 一样,将路径路由到public?还是结构的其他部分?

感谢您的建议。

【问题讨论】:

    标签: deployment crystal-lang amber-framework


    【解决方案1】:

    Amber 将为您提供静态资产,只需将 nginx 指向端口 3000。

    这是 nginx 配置作为 Amber 在端口 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;
      }
    }
    

    然后,用 AMBER_ENV=production 启动 Amber:

    #!/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
    

    这一切都假设您的 amber 应用程序名为 app

    【讨论】:

    • 您可以使用shards build test --poduction,而无需在之前运行shards install :)
    • 是的,这是一个很好的解决方案。从技术上讲,您也可以在不使用 nginx 的情况下进行部署,但这需要在端口 80 或 443 上运行 Amber,这需要对 Web 应用程序进行超级用户访问(通常不推荐)。
    • @NickM 是的,我相信 apache 模块 proxy 提供与 nginx proxy_pass 基本相同的功能。
    猜你喜欢
    • 1970-01-01
    • 2017-02-01
    • 2022-01-13
    • 1970-01-01
    • 2017-09-02
    • 2021-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多