Skip to content

Instantly share code, notes, and snippets.

@leapar
Last active April 5, 2019 02:39
Show Gist options
  • Save leapar/30927dccba3fd539f8b43803bca03810 to your computer and use it in GitHub Desktop.
Save leapar/30927dccba3fd539f8b43803bca03810 to your computer and use it in GitHub Desktop.
在windows上面基于virtualbox安装flynn

为什么要flynn,它比deis heroku还牛逼,未来估计要火。当然,你学deis,heroku都可以,选择就是赌博,我就赌为了flynn。就跟赌kong reactjs一样。

  • 安装

    手工安装真他妈要死人,网络太慢。挂机在ubuntu上面安装了16个小时,没错,我就一直等到晚上2点才安装完。还是用vagrant安装吧,舒服。

    git clone https://github.com/flynn/flynn
    cd flynn/demo
    
    1. 下载文件:

      https://dl.flynn.io/vagrant/flynn-base.json

      https://dl.flynn.io/vagrant/boxes/flynn-base_v20161017.1_virtualbox.box

    2. 修改vagrant.file

    config.vm.box_url = "https://dl.flynn.io/vagrant/flynn-base.json"

    修改成

    config.vm.box_url = "https://127.0.0.1:82/leapar/vagrant/flynn-base.json"

    1. 修改flynn-base.json

    url: "https://dl.flynn.io/vagrant/boxes/flynn-base_v20161017.1_virtualbox.box"

    改成

    url: "https://127.0.0.1:82/leapar/vagrant/boxes/flynn-base_v20161017.1_virtualbox.box"

    1. 执行vagrant up

    2. 等待

    ==> default: Flynn bootstrapping complete. Install the Flynn CLI (see https://flynn.io/docs/cli for instructions) and paste the line below into a terminal window:
    ==> default:
    ==> default: flynn cluster add -p Bm0TzBPk9dOGab46EOzlrsBXzN1dDCBTf3CJKInAAHY= default demo.localflynn.com 9c7c346247b41d8f3612e8ef65039eca
    ==> default:
    ==> default: The built-in dashboard can be accessed at http://dashboard.demo.localflynn.com and your login token is 85ba50b483faca5b1326cc20c3e3cf5b
    
    1. 配置

    用ssh进入127.0.0.1:2222 如果没错应该ifconfig是192.2.0.200.然后修改windows的hosts

    192.0.2.200         localflynn.com
    192.0.2.200         example.com
    

    打开https://dashboard.demo.localflynn.com ,然后安装根发行证书,输入上面的token,就看见你期待的界面了。

    1. ps

    flynn install 会打开网页,也可以界面话安装,但是我没有成功。

  • 维护

    vagrant suspend vagrant resume

  • 发布 在dashboard里面关联了我的github账号,但是点luanche安装一直失败。所有我采用手工安装: 在https://github.com/flynn-examples/ 下面有好多example,我安装了nodejs、php、go、以及static的,java的没有安装。下面开始举例:

      $git clone https://github.com/flynn-examples/go-flynn-example
    
      $cd go-flynn-example
      $flynn create example
      Created example
    
      $ git remote -v
      flynn   https://git.demo.localflynn.com/example.git (push)
      flynn   https://git.demo.localflynn.com/example.git (fetch)
      origin  https://github.com/flynn/nodejs-flynn-example.git (fetch)
      origin  https://github.com/flynn/nodejs-flynn-example.git (push)
    

    这个可以不要,最后到dashboard上面去追加也可以。main.go里面使用了postgre,另外几个example是没使用的。flynn自带了redis、mysql、postgres、mongodb, 你自己也可以使用外部数据库,在flynn env中修改。

    $ flynn resource add postgres
    Created resource 320f38ba-36bc-40ce-97e5-dad1b5c3bd20 and release c7b793ca-b7b1-4da0-bd1d-4ed95c1b52e8.
    

    如果上面你追加了数据库,那么下面命令会看见数据库。

    $ flynn env
    DATABASE_URL=postgres://84abab8e4000453fe2e1ce3f4f04392a:[email protected]:5432/7f02ee75fe57cb70fe1e5d9afc37935c
    FLYNN_POSTGRES=postgres
    PGDATABASE=7f02ee75fe57cb70fe1e5d9afc37935c
    PGHOST=leader.postgres.discoverd
    PGPASSWORD=80f9191af9ae6c7890e4caae54990255
    PGUSER=84abab8e4000453fe2e1ce3f4f04392a
    
    $ git push flynn master
    Counting objects: 728, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (451/451), done.
    Writing objects: 100% (728/728), 933.29 KiB | 0 bytes/s, done.
    Total 728 (delta 215), reused 728 (delta 215)
    -----> Building example...
    -----> Go app detected
    -----> Checking Godeps/Godeps.json file.
    -----> Installing go1.6.3... done
    -----> Running: go install -v -tags heroku .
    -----> Discovering process types
           Procfile declares types -> web
    -----> Compiled slug size is 3.6M
    -----> Creating release...
    =====> Scaling initial release to web=1
    -----> Waiting for initial web job to start...
    =====> Initial web job started
    =====> Application deployed
    To https://git.1.localflynn.com/example.git
     * [new branch]      master -> master
    

    如果上面出错,再执行一遍,成功的话,可以看见内容了。

    $ curl http://example.demo.localflynn.com
     Hello from Flynn on port 8080 from container db0440f7-19b4-4369-b79e-7a48dba415c2
     Hits = 1
    
  • 进阶

 你可以在dashboard中为http://example.demo.localflynn.com 添加路由为example.com,当然host要修改。 问题来了:

 为什么我git push flynn master就会自动部署安装,包括php、apache、nodejs、go等等运行环境?

 首先你要知道有npm、composer、maven、go get然后你要知道deis heroku。  flynn基于heroku的builder制作的,当git push时候,flynn/gitreceive/receiver/flynn-receive.go会监测是否完成,如果完成那么就启flynn/slugbuilder去进行部署。这就是他的核心。  另外flynn scale路由等等自己去发现,其实kong的很多内容flynn已经做了很多,两者怎么结合,自己玩去吧。

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