This is an old revision of the document!
Table of Contents
medAL-data Setup
Purpose and Scope
This page lists instructions to setup a medAL-data server instance and is intended to be read carefully by the entities involved in setting up the various components of the medAL suite.
Material
You will need the following material:
- A Linux server with the following minimal requirements:
- 8GB RAM
- 300GB disk capacity
- Operating System: Ubuntu >= 18.04
- A controlling workstation (Linux / MacOS / Windows) with the following installed:
- git version control software (see https://git-scm.com/)
- bash terminal (for windows see : https://gitforwindows.org/)
- A domain Name (In the installation we will use the name example.com) pointing to the server's IP address.
Manual Installation
Environment Setup
Firstly, open up two terminals [t_local] and [t_remote] on the controlling workstation, on [t_remote] connect to the root account of the remote server using ssh:
ssh root@example.com
Dokku Installation on Remote Server
To setup the dokku installation, follow these steps:
- [t_remote] Install dokku with the following commands:
wget https://raw.githubusercontent.com/dokku/dokku/v0.24.10/bootstrap.sh sudo DOKKU_TAG=v0.24.10 bash bootstrap.sh
To get the latest verison go to https://dokku.com/docs/getting-started/installation/
- [t_local] On the local workstation, open a browser and head to your server domain
example.com
where you will be able to setup the public SSH key used when deploying the source code to the server and optionnaly enable virtual hosting on the server: - If you already have a ssh key configured for git on your local workstation, then copy the value of the public key and paste in the dialog on dokku's web interface. If you already have a public key then you can copy the value output from the command:
cat ~/.ssh/id_rsa.pub
, or generate a new one using:
ssh-keygen -t rsa
- Enter your domain name
example.com
in the corresponding dialog box
Application Setup
Application Deployment
Now, deploy your application by following this procedure:
- [t_remote] Run the following commands to create and configure the dokku app for the medAL-data server:
# Create the App dokku apps:create medal-data # Install the postgres DB plugin sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres # Create Database dokku postgres:create medal-data-db # Link the App to the database dokku postgres:link medal-data-db medal-data # Set Config variables for Laravel dokku config:set medal-data DB_CONNECTION=postgres # Add the PHP buildpack to the apps config dokku config:set medal-data BUILDPACK_URL="https://github.com/heroku/heroku-buildpack-php" # Configure the storage folder of the server mkdir -p /var/lib/dokku/data/storage/medal-data mkdir -p /var/lib/dokku/data/storage/medal-data/framework mkdir -p /var/lib/dokku/data/storage/medal-data/framework/sessions mkdir -p /var/lib/dokku/data/storage/medal-data/framework/cache mkdir -p /var/lib/dokku/data/storage/medal-data/framework/views # give rights to herokuish chown -R 32767:32767 /var/lib/dokku/data/storage/medal-data dokku storage:mount medal-data /var/lib/dokku/data/storage/medal-data:/app/storage # set the scale of the application dokku ps:scale medal-data web=1 worker=1
- [t_local] On the local workstation, clone the source code of the medal-data server from the bitbucket repository:
git clone https://informatique_unisante@bitbucket.org/wavemind_swiss/liwi-main-data.git
, and navigate to the project folder:
cd liwi-main-data
- [t_local] Do a copy the
.env.dokku.example
file and name it.env.dokku
:
cp .env.dokku.example .env.dokku
and fill out the values depending on your desired configuration:
sudo nano .env.dokku
Then copy the file content to your clipboard.
- [t_remote] On the remote server, paste the content at the end of the following file:
/home/dokku/medal-data/ENV
. - [t_local] Link and deploy the server with the following git commands (replace example.com with your own domain name):
git remote add dokku dokku@example.com:medal-data git push dokku master
If the push did not work, then make sure you have correctly set up the SSH key on the dokku server using the web interface (more information on https://dokku.com/docs/deployment/user-management/).
- [t_remote] Back on the remote server, run the following command to set the
APP_KEY
environment variable:
dokku config:set medal-data APP_KEY=$(dokku run medal-data php artisan --no-ansi key:generate --show) --no-restart
- [t_remote] Also run the following command to make sure that Laravel's passports encryption keys are properly generated:
dokku run medal-data php artisan passport:keys
- Make sure that to setup the ther environment variables properly in your
.env
file. You can find an exhaustive list of environment variables here. - Refresh the configuration:
dokku run medal-data php artisan config:cache - **[t_remote]** Finally, migrate and seed the database using: \\ <code> dokku run medal-data php artisan migrate:fresh --seed --force
- [t_remote] medAL-data automatically implements a Two-factor authentication strategy. Run the following command to generate 2FA codes:
dokku run medal-data php artisan 2fa:authenticate_all
and confirm by typing
yes
. For more information about Two-factor authentication, click here.