Docker
This guide explains how to install and run Kyso using Docker and Docker Compose

Prerequisites

  • A Docker-enabled system with proper Docker access
  • Access to Kyso's private docker image hub
  • Internet access
Internet access is only needed during the installation process if Kyso is hosted where it can access Amazon S3 buckets locally

Option 1: Install Kyso with Docker

Set up Kyso container's with a MongoDB database

Pull all the required images

docker pull mongo:5.0.5
docker pull kyso/backend
docker pull kyso/frontend
Kyso docker images are not in Docker Hub, so they are not publicly available. In order to download the images, you must have access to our private docker image repository. If you don't have access, please contact us on [email protected]

Prepare the database

Kyso API check on startup if the database has the collections and the minimal data required to run, so you don't need to create any collection or apply any script.
However, it is necessary to configure the user that will have access to the database, and to set the name of the database that Kyso will use.
Create a custom Docker network to allow the containers to discover and communicate with
docker network create kyso-network
You can change the name of the network (kyso-network) for one of your preference
Create a folder in your local file system, which will store the data of MongoDB outside the container, and another folder to store the initial configuration
mkdir mongo-volume
mkdir docker-entrypoint.initdb.d
Enter into docker-entrypoint.initdb.d folder and create mongo-init.js file with the following contents
db = new Mongo().getDB("kyso");
db.createUser(
{
user: 'kysodb',
pwd: 'kysodb',
roles: [{ role: 'readWrite', db: 'kyso' }],
},
);
Please, use strong and unguessable passwords in a production environment
Go back to the original folder and start a MongoDB container
docker run -d --name kyso-db \
--network=kyso-network \
-p 27017-27019:27017-27019 \
-e "MONGO_INITDB_ROOT_USERNAME=kadmin" \
-e "MONGO_INITDB_ROOT_PASSWORD=ksecret" \
-v docker-entrypoint-initdb.d/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
-v mongo-volume:/data/db \
mongo:5.0.5
On the first execution, MongoDB will create the users, and once it's finished, the container will shutdown. To run the container again just run the following command
docker container start kyso-db
To check that the container is running
[email protected] % docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
03a38df7928b mongo:5.0.5 "docker-entrypoint.s…" 6 minutes ago Up 2 minutes 0.0.0.0:27017-27019->27017-27019/tcp kyso-db

Prepare the API

Start a Kyso API container
docker run -d --name kyso-backend \
--network=kyso-network \
-p 3000:3000 \
-e "DATABASE_URI=mongodb://kadmin:[email protected]/kyso-initial?retryWrites=true&w=majority" \
-e "NODE_ENV=production" \
-e "SELF_URL=http://localhost:3000" \
-e "KYSO_FILES_CLOUDFRONT_URL=http://url-to-cloudfront" \
-e "AWS_REGION=your-bucket-s3-region" \
-e "AWS_S3_BUCKET=your-bucket-s3-name" \
-e "S3_BUCKET=your-bucket-s3-name" \
-e "AWS_ACCESS_KEY_ID=your-aws-access-key" \
-e "AWS_SECRET_ACCESS_KEY=your-aws-access-key-secret" \
-e "AUTH_GITHUB_CLIENT_ID=your-github-client-id" \
-e "AUTH_GITHUB_CLIENT_SECRET=your-github-client-secret" \
-e "AUTH_GOOGLE_CLIENT_ID=your-google-client-id" \
-e "AUTH_GOOGLE_CLIENT_SECRET=your-google-client-secret" \
kyso/backend
Please ensure that the DATABASE_URI property matches with the database configuration established in the previous section
To disable social login with Github and Google, just let the environment variables AUTH_GOOGLE and AUTH_GITHUB unset

Prepare the frontend

Start a Kyso container
docker run -d --name kyso-frontend \
--network=kyso-network \
-p 3000:80 \
-e "NODE_ENV=production" \
-e "API_URL=http://localhost:3000" \
-e "NEXT_PUBLIC_API_URL=http://localhost:3000" \
kyso/frontend
We strongly recommend to use secrets instead of environment variables

Option 2: Install Kyso with Docker Compose

Docker compose is a more simpler way to deploy Kyso, instead of using directly the docker images.
Create a folder in your local file system, which will contain the Docker Compose file, and the initial configuration of MongoDB
mkdir kyso-deployment
cd kyso-deployment
Then, create a new folder inside as follows
mkdir docker-entrypoint.initdb.d
cd docker-entrypoint.initdb.d
Then, create a mongo-init.js file with the following contents
db = new Mongo().getDB("kyso");
db.createUser(
{
user: 'kysodb',
pwd: 'kysodb',
roles: [{ role: 'readWrite', db: 'kyso' }],
},
);
Please, change the password to a robust and unguessable one
Then, go to kyso-deployment folder and create a docker-compose.yml file with the following contents
version: '3.7'
services:
kyso-db:
image: mongo:5.0.5
container_name: mongodb
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: kadmin
MONGO_INITDB_ROOT_PASSWORD: ksecret
ports:
- 27017:27017
volumes:
- ./docker-entrypoint-initdb.d/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
kyso-backend:
image: kyso/kyso-backend
container_name: kyso-backend
restart: always
environment:
DATABASE_URI: mongodb://kysodb:[email protected]/kyso?retryWrites=true&w=majority
DATABASE_NAME: kyso
NODE_ENV: production
SELF_URL: http://localhost:3000
KYSO_FILES_CLOUDFRONT_URL: http://url-to-cloudfront
AWS_REGION: your-bucket-s3-region
AWS_S3_BUCKET: your-bucket-s3-name
S3_BUCKET: your-bucket-s3-name
AWS_ACCESS_KEY_ID: your-aws-access-key
AWS_SECRET_ACCESS_KEY: your-aws-access-key-secret
AUTH_GITHUB_CLIENT_ID: your-github-client-id
AUTH_GITHUB_CLIENT_SECRET: your-github-client-secret
AUTH_GOOGLE_CLIENT_ID: your-google-client-id
AUTH_GOOGLE_CLIENT_SECRET: your-google-client-secret
ports:
- 3000:3000
links:
- 'kyso-db'
depends_on:
- kyso-db
kyso:
image: kyso/frontend
container_name: kyso-frontend
restart: always
environment:
NODE_ENV: production
API_URL: http://localhost:3000
NEXT_PUBLIC_API_URL: http://localhost
ports:
- 3001:3000
Remember to change the environment variable DATABASE_USE with the password you set up in mongo-init.js
Finally, execute the following command
docker compose up

Test the installation

In order to check that the API is up and running, just open http://localhost:3000/redoc in your browser
To check that the frontend is up and running, just open http://localhost:3001/login in your browser
Login page