apex / up

Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS.
https://up.docs.apex.sh
MIT License
8.79k stars 377 forks source link

How to use PRO on CI machine #421

Closed cloudkite closed 6 years ago

cloudkite commented 6 years ago

I have been using UP in production for a while now and just purchased the PRO ❤️

I'm currently using the community version with simple variable substitution to automatically deploy from CI.

How do I login and install the PRO version from a CI build machine so I can start using the new encrypted ENV features?

Thanks!

tj commented 6 years ago

thanks for subscribing :D make sure to watch #415, should have it ready today

cloudkite commented 6 years ago

Awesome thanks 👍

tj commented 6 years ago

I still have to document and simplify this, but for a Node app you'd do:

npm install -g yarn
yarn
sudo chown -R $(whoami) /usr/local/bin
curl -sfL https://raw.githubusercontent.com/apex/up/master/install.sh | sh
up upgrade
up deploy production

For env vars in Semaphore/Circle/Travis etc you'll need:

Where UP_CONFIG is your ~/.up/config.json file (as a single line so it can be stored in an env var).

I'll add some command like up config copy to grab copy that to your clipboard easier

cloudkite commented 6 years ago

@tj thanks already doing something very similar to this.

I was more thinking if I add an env through up on my local pro version. ie: up env add DB_URL stage.mydb.hosted.com

Will the CI built deployment be able to read that env since it is not logged into my PRO up account?

tj commented 6 years ago

ohhh I see what you mean, currently that won't work. You have to upgrade in CI as well, because the binary running on Lambda is baked into the Up binary, so you would end up running the version of Up which does not load the env vars at all.

I'll make sure to document that, it's definitely not clear.

cloudkite commented 6 years ago

@tj the CI I'm using runs off docker images. Not really sure how I would go about logging in and upgrading on a docker image?

tj commented 6 years ago

Hmm which CI service? Every one I’ve seen lets you edit the commands and env vars so that should be enough hopefully!

cloudkite commented 6 years ago

@tj I'm using wercker which is based on docker.

Sorry I dont think I made my question clear.

In-order to download the PRO binary you need todo up account login

which requires input and verification via email? how todo this in a docker image?

tj commented 6 years ago

ahh you can use UP_CONFIG now (https://github.com/apex/up/commit/baa7fbeb6f8703065bfd15ebcb074f5430751af5#diff-e7fbf301bb4b227cbd056102c31519f1R43 for example), which is the contents of your ~/.up/config.json file. So as long as you can set the AWS env vars and that UP_CONFIG one you should be good to go.

I'll make this easier but for now you can grab the contents with:

$ cat ~/.up/config.json | tr -d '\n'
cloudkite commented 6 years ago

Thanks @tj got it working using up account login --email my@email.com to avoid input on docker

Two things I stumbled across while configuring PRO on CI:

  1. Would be nice to be able to specify a version when you up upgrade so that you can have a predictable version of up PRO on your docker instance and then it would be possible to test and opt into version bumps or rollback if you encounter a breaking change

  2. Docker by default runs in root directory and up account login seems to try use the current dir as app name so ended up get this error:

Error: initializing: reading config: validating: .name "/": must contain only alphanumeric characters and '-'

As a workaround I created a dummy dir so that it wouldnt complain about the dir name

RUN mkdir hello && cd hello && up account login --email my@email.com && up upgrade
tj commented 6 years ago

Totally agree about the upgrade version (#387 if you want to sub), not ideal to fetch any random version that's for sure, I'll try and prioritize that.

Regarding the name issue there, that shouldn't happen if you have a up.json "name" field, by default it uses the directory's name. I might remove that entirely soon though, requiring an up.json file isn't a huge deal (#386)

cloudkite commented 6 years ago

cool makes sense thanks!

kaihendry commented 6 years ago

I think I have a working example here:

Bit scary to use my AWS_ACCESS_KEY_ID key here. I wonder if my UP_CONFIG can be tied the a specific AWS_PROFILE. Since I've noticed my UP_CONFIG is actually my work place one.

lukeed commented 6 years ago

Posting TJ's guide on Medium just because it's not included yet.