This is the production setup of BIIGLE. You can fork this repository to customize your own production instance.
Perform these steps on the machine that should run BIIGLE. Check out the wiki for an example of how to prepare a new machine for the installation of BIIGLE.
-
Create a user for BIIGLE and find out the user and group ID:
$ sudo useradd biigle -U $ id -u biigle <user_id> $ id -g biigle <group_id>
-
Change the owner of the
storage
directory:$ sudo chown -R biigle:biigle storage/
-
Move
.env.example
to.env
. -
Now set the configuration variables in
.env
:USER_ID
should be<user_id>
.GROUP_ID
should be<group_id>
.
-
Move
build/.env.example
tobuild/.env
. -
Now set the build configuration variables in
build/.env
:GITHUB_OAUTH_TOKEN
is an OAuth token of your GitHub account.APP_KEY
is the secret encryption key. Generate one with:head -c 32 /dev/urandom | base64
. Then setAPP_KEY=base64:<your_key>
.APP_URL
ishttps://<your_domain>
.ADMIN_EMAIL
is the email address of the administrator(s) of the application.
-
If you use an external database system (outside Docker), remove the
database
block fromdocker-compose.yaml
and configure theDB_*
variables inbuild/.env
. -
Put the SSL keychain (
fullchain.pem
) and private key (privkey.pem
) tocertificate/
. See here for a description of the required contents of the keychain file. -
Now build the Docker images for production:
cd build && ./build.sh
. You can build the images on a separate machine, too, and transfer them to the production machine usingdocker save
anddocker load
.build.sh
also supports an optional argument to specify the version tag of the Docker containers to build (e.g.v2.8.0
). Default islatest
. -
Go back and run the containers:
cd .. && docker-compose up -d
. -
Apply the database migrations:
./artisan migrate
. -
Create the first user:
./artisan user:new
.
-
Get the newest versions of the Docker images:
docker pull docker.pkg.github.com/biigle/core/app:latest docker pull docker.pkg.github.com/biigle/core/web:latest docker pull docker.pkg.github.com/biigle/core/worker:latest
-
Run
cd build && ./build.sh
. This will fetch and install the newest versions of the BIIGLE modules, according to the version constraints configured inbuild.sh
. Again, you can do this on a separate machine, too (see above). In this case the images mentioned above are not required on the production machine. -
If the update requires a database migration, do this:
- Put the application in maintenance mode:
./artisan down
. - Do a database backup. This might look along the lines of:
docker exec -i $(docker-compose ps -q database) pg_dump -U biigle -d biigle > biigle_db.dump
- Put the application in maintenance mode:
-
Update the running Docker containers:
docker-compose up -d
. -
If the update requires a database migration, do this:
- Run the migrations
./artisan migrate
- Turn off the maintenance mode:
./artisan up
- Run the migrations
-
Run
docker image prune
to delete old Docker images that are no longer required after the update.
BIIGLE runs as an ensemble of multiple Docker containers (called "services" by Docker Compose).
app
runs the BIIGLE PHP application that handles user interactions.web
accepts HTTP requests, forwards them to the PHP application or serves static files.worker
executes jobs from the asynchronous queue which are submitted byapp
. This is the only service that runs multiple Docker containers in parallel.scheduler
runs recurring tasks (similar to cron jobs).cache
provides the Redis cache that BIIGLE uses.database
provides the PostgreSQL database that BIIGLE uses.
To interact with these services rather than individual Docker containers, you have to use Docker Compose. Here are some common tasks a maintainer of a BIIGLE instance might perform using Docker Compose.
docker-compose logs [service]
This shows the log file of the [service]
service. You can use --tail=[n]
to show only the last [n]
lines of the log file and -f
to follow the log file in real time.
docker-compose restart
This may be required if a service crashed or if file system mounts changed.
./artisan [command]
This runs the artisan command [command]
in the worker service.
./artisan tinker
This opens the interactive PHP shell that you can use to manipulate BIIGLE. The shell only runs in the worker
service as a debugging mechanism.
docker-compose up -d --scale worker=[n]
Set the number of worker containers running in parallel to [n]
. If you want this to persist, set scale: [n]
for the worker service in docker-compose.yaml
.