The quickest and most maintainable way to get a production INK instance up and running is using Docker. INK is provided as a dockerised service, and can be run along with all dependency services using docker compose. This guide shows you how to do that, with commands designed for a fresh ubuntu LTS (16.04) installation.
You'll need Node.JS, preferably via a Node version manager.
On ubuntu:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"To confirm nvm is installed:
command -v nvmThis should print nvm.
Now to install the latest version of Node.JS:
nvm install --ltsTo confirm Node.JS is installed and selected:
nvm lsYou should see something like:
-> v8.9.1
system
default -> 8 (-> v8.9.1)
node -> stable (-> v8.9.1) (default)
stable -> 8.9 (-> v8.9.1) (default)
lts/* -> lts/carbon (-> v8.9.1)
lts/carbon -> v8.9.1
Next you'll need ruby, preferably via a ruby version manager.
On ubuntu:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable --ruby=2.2.3
source /usr/local/rvm/scripts/rvmTo confirm the rvm and the correct ruby version are installed, run:
rvm lsYou should see:
rvm rubies
=* ruby-2.2.3 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Bundler is used to manage ruby dependencies for INK. To install bundler, we use the ruby gem package manager:
gem install bundlerYou'll need to install docker and docker-compose.
On ubuntu:
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get -y install \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-composeINK is downloaded from its Gitlab repository.
We will do this using git (but you can also download and unpack the repo in zip or tar.gz formats).
To clone the repo:
git clone -b production-docker https://gitlab.coko.foundation/blahah/ink-apithen cd ink-api to set the repository as your working directory.
We need to configure the various services that INK will depend on before we run them. We do this by creating a .env file containing environment variables that will be added into the environment of each docker container when it runs.
To generate a .env file, you run the generator script (./bin/create-env) and provide it with:
- the IP address or hostname of the server
- an email address for the server admin
E.g.:
./bin/create-env 123.34.45.56 [email protected]The script populates the .env file with securely generated secret keys for the various services INK relies upon, and adds all necessary config options.
We use docker and docker-compose to build and run the INK containers:
docker volume create --name gems
./bin/dockerNow you should be inside the running INK docker container. We now install the ruby dependencies and set up the database:
bundle
rake db:create
rake db:schema:load
rake db:seedKeep this terminal window open
Before we run the server, we first need to download the client-side code and generate a browser bundle using the same settings as we used for the server.
Note: Do all the following steps in a new terminal window
As with ink-api, we will download the ink-client code from its Gitlab repository.
We will do this using git (but you can also download and unpack the repo in zip or tar.gz formats).
Note: you should place the ink-client repo in the same directory that contains ink-api in order for all the following commands to work
To clone the repo:
git clone https://gitlab.coko.foundation/INK/ink-client.gitthen cd ink-client to set the repository as your working directory.
We need to set the IP/host of the server, and set up the secure communication between client and server.
To do this we edit two files:
./settings.js
- replace
http://ink-api.coko.foundationwith your own IP or hostname, e.g.http://123.23.34.45
./config/slanger-production.yml
- replace all IP addresses with your own IP or hostname
- replace the
app_key(set to44332211ffeeddccbbaaby default) with the value ofSLANGER_KEYfrom theink-api.env
First we need to install the dependencies:
npm installNext, to generate all the necessary app bundle files, we run
npm run buildThis creates all the bundle files in ./dist, and starts a server with them. Kill the server using ctrl C to return to a command-line prompt.
Now we copy all the client files to where the server can find them.
Assuming you placed ink-client in the same directory as ink-api:
cp -R src/fonts src/images dist/
cp -R dist/* ../ink-api/public/All the files should now be in place to allow us to run the server and client.
Return to the ink-api terminal window and run the app:
./bin/serverNow you can go to http://YOUR_HOSTNAME_OR_IP:3000 and log in. The default account is:
- username:
[email protected] - password:
password