From f2c58d545abe7833cc99601d9575d0603fbe9125 Mon Sep 17 00:00:00 2001 From: Minghe Date: Fri, 15 Nov 2019 13:29:31 +0800 Subject: [PATCH] add document on ubunut (#352) * add document on ubunut * fix typo --- docs/lightsail.yml | 16 ------------- docs/ubuntu.md | 52 ++++++++++++++++++++++++++++++++++++++++++ hack/install_docker.sh | 20 +++++++--------- 3 files changed, 60 insertions(+), 28 deletions(-) delete mode 100644 docs/lightsail.yml create mode 100644 docs/ubuntu.md diff --git a/docs/lightsail.yml b/docs/lightsail.yml deleted file mode 100644 index 4ab28d6f..00000000 --- a/docs/lightsail.yml +++ /dev/null @@ -1,16 +0,0 @@ -# fx on Amazon Lightsai - -* make sure your instance have docker installed and running, -* make sure your instance can be ssh login (with user and password) - -``` -ssh @ -``` - -* make sure your instance accept port 8866 - -* then you can deploy function to remote host - -``` -DOCKER_REMOTE_HOST_ADDR= DOCKER_REMOTE_HOST_USER= DOCKER_REMOTE_HOST_PASSWORD= ./build/fx up -p 1234 test/functions/func.js -``` diff --git a/docs/ubuntu.md b/docs/ubuntu.md new file mode 100644 index 00000000..60c35ccc --- /dev/null +++ b/docs/ubuntu.md @@ -0,0 +1,52 @@ +# fx on Ubuntu + +> The guide is verified on Amazon Lightsail ubuntu 18.08 instance + +## Install Docker + +```shell +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 + +```shell +$ curl -o- https://raw.githubusercontent.com/metrue/fx/master/scripts/install.sh | sudo bash +``` + +## Deploy a function onto localhost + +```shell +$ 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 your instance can be ssh login +* make sure your instance accept port 8866 + + +If you're first time to deploy a function to remote host, you need init it first +```shell +DOCKER_REMOTE_HOST_ADDR= DOCKER_REMOTE_HOST_USER= DOCKER_REMOTE_HOST_PASSWORD= fx init +``` + +then you can deploy function to remote host + +```shell +DOCKER_REMOTE_HOST_ADDR= DOCKER_REMOTE_HOST_USER= DOCKER_REMOTE_HOST_PASSWORD= fx up -p 2000 test/functions/func.js +``` diff --git a/hack/install_docker.sh b/hack/install_docker.sh index dc30e8a6..5aa362e1 100755 --- a/hack/install_docker.sh +++ b/hack/install_docker.sh @@ -3,15 +3,11 @@ set -e # ++ # verified on Ubuntu 16.04 x64 # ++ -user_host=$1 - -ssh ${user_host} 'bash -s' <