Files
fx-serverless/docs/ubuntu.md
2020-03-19 13:30:28 +08:00

1.3 KiB

fx on Ubuntu

The guide is verified on Amazon Lightsail ubuntu 18.08 instance

Install Docker

apt-get remove -y docker docker-engine docker.io containerd runc
apt-get update -y
apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-core
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update -y
apt-get install -y docker-ce
docker run hello-world

Install fx

$ curl -o- https://raw.githubusercontent.com/metrue/fx/master/scripts/install.sh | sudo bash

Deploy a function onto localhost

$ cat func.js

module.exports = (ctx) => {
  ctx.body = 'hello world'
}

$ fx up -n test -p 2000 func.js
$ curl 127.0.0.1:2000

Deploy a function onto remote host

  • make sure you can ssh login to target host with root

Update /etc/ssh/sshd_config to allow login with root.

PermitRootLogin yes

Then restart sshd with,

$ sudo service sshd restart
  • make sure your instance accept port 8866

FYI

then you can deploy function to remote host

fx up --host root@<your host> test/functions/func.js