# Labkey as a docker container

This git project contains everything required to start labkey as a docker container.

## Installation

### Prepare

- Install [`docker`][docker] and [`docker-compose`][dockerCompose]
- create a user `labkey` with `docker` privileges
```bash
sudo adduser labkey
sudo -G docker labkey
```
- clone the software directly into home
```bash
sudo su labkey
git init .
git remote add origin <repository-url>
git pull origin master
```
- run `bin/installLabkey.sh 22.3` to unzip the enclosed LabKey binary code and make appropriate links.
- copy `bin/env.sh.sample` to `bin/env.sh` and set a secret `$PGPASS`, other settings are probably OK, 
  check `$DOCKERCOMPOSE`
- set the same value as `password` in `labkey/labkey.yml` 
  
### Start containers
  
Run `bin/startLabkey.sh`. This will do several things:
   - Download PostgreSQL image and initialize a persistent database at `~/postgresl/data`. 
  - Build a combined tomcat/R image from a recent version of tomcat
  - Copy and link files from home to the server
  - Start the server

### Check the installation
  
In principle, the service should be running at `http://localhost:8443/labkey`. Check output of inidividual 
  components by:
  
```bash
  docker logs config-db-1
  docker logs config-web-1
  docker exec -it config-db-1 bash
```
  
### Expected errors
  
Errors of the type `500: Unexpected server error` are common and related 
  
[docker]: https://docs.docker.com/engine/install/centos/
[dockerCompose]: https://docs.docker.com/compose/install/