vapor项目部署到heroku过程

2019-02-08  本文已影响0人  小熊翻译App

: heroku-18部署失败的解决方案:heroku-16 和 heroku-18的相互切换

  1. Vapor swift开发数据库安装和heroku设置
  2. heroku-16 和 heroku-18的相互切换
1. 终端登录heroku
heroku login
2. cd切换到vapor项目根目录后执行:
vapor heroku init

过程如下:

// 自定义app名字
Would you like to provide a custom Heroku app name?
y/n> y
Custom app name:
> youAppName  
// Choose a region: US OR Europe       
Would you like to deploy to a region other than the US?
y/n> n

Would you like to provide a custom Heroku buildpack?
y/n> y

Are you using a custom Executable name?
y/n> n

Would you like to push to Heroku now?
y/n> y

其中: buildpack 可以在heroku官网项目的setting设置为:

https://github.com/vapor-community/heroku-buildpack.git

如下图:


image.png

也可以在终端设置:

heroku buildpacks:set https://github.com/kylef/heroku-buildpack-swift.git
3. 增加Procfile和.swift-version文件

1>检查项目根目录是否有 Procfile 文件,如果没有在终端执行创建Procfile:

touch Procfile

2>打开 Procfile 将下面的配置复制到文件

web: Run serve --env production --hostname 0.0.0.0 --port $PORT
  1. 配置数据库,终端执行下面的命令:
heroku addons:create heroku-postgresql:hobby-dev
  1. 更新部署,依次执行下列3个命令:
git add .
git commit -am "make it better"
git push heroku master

6.终端输入:

heroku ps:scale web=1
  1. 回到heroku官网项目后台
上一篇下一篇

猜你喜欢

热点阅读