To develop BIIGLE on your local machine you can use Docker containers. This way you don't need to install any of the requirements such as Python or special PHP extensions and keep your development environment clearly separated from your regular system.
First, install the following software:
- PHP >= 8.0
- Docker Engine
- Docker Compose
- Composer
- Recommended: The
unzip
tool
Important
The link above points to Docker Engine on purpose. Docker Desktop (on Linux) may have problems mounting the filesystem with the correct permissions.
On Linux: Make sure to add your user to the new docker
group with sudo usermod -aG docker $(whoami)
, then log out and back in. Otherwise you have to call all docker
or docker compose
commands with sudo
.
Now you can proceed with the development setup:
Optional: If you want to contribute code changes to this repository, you need to fork it (unless you are a member of the BIIGLE GitHub organization). Use the URL of your fork in the command below (e.g. git@github.com:YOUR_GITHUB_NAME/core.git
). You can also create the fork and update the Git remote URL later. If you want to contribute to a module, please see below after the main application is up an running.
Set up the project in the biigle
directory (this may take a while):
composer create-project biigle/core:dev-dev-modules \
--repository='{"type":"vcs","url":"git@github.com:biigle/core.git"}' \
--keep-vcs \
--ignore-platform-reqs \
biigle
Note the --ignore-platform-reqs
flag to keep Composer from complaining about missing requirements. These requirements will be met by the Docker containers.
This will set up the project in the dev-modules
branch of this repository. The dev-modules
branch is configured with all BIIGLE modules which makes it easy to start module development. If you want to develop a feature directly in biigle/core
, please switch to the master
branch (or create your own branch based on master
). Pull requests from a dev-modules
-based branch will not be accepted.
Optional: To speed up the build process, download the pre-built Docker images from GitHub:
docker pull ghcr.io/biigle/app:latest
docker pull ghcr.io/biigle/web:latest
docker pull ghcr.io/biigle/worker:latest
Now perform these steps:
-
Switch to the new
biigle
directory:cd biigle
-
(You can skip this step if you already pulled the images above.) Build the Docker images with
docker compose build
. This takes a while. -
Check your user ID with
id -u
. If it isn't1000
, updateUSER_ID
andGROUP_ID
in the.env
file. -
Start the first containers:
docker compose up -d app
-
Apply the database migrations:
docker compose exec app php artisan migrate
-
Start the whole application with
docker compose up -d
. The BIIGLE application is now running at http://localhost:8000. You can stop the containers withdocker compose stop
or destroy them withdocker compose down
. To delete the development database as well, rundocker volume prune
after the containers were destroyed.
The JavaScript and asset source files are located in resources/assets
. The files are built using NPM and Laravel Mix. Before you start, you have to configure NPM to authenticate to GitHub:
-
Create a new personal access token with the
read:packages
scope. -
Create a new file
~/.npmrc
and insert the following content://npm.pkg.github.com/:_authToken=TOKEN
Replace
TOKEN
with the personal access token of step 1. -
Now run
npm install
to install the dependencies (this requires NodeJS >=12.14).
Important commands for development are:
-
npm run watch
: Starts a continuous process to watch for file changes. Rebuilds the assets whenever a file is changed. This can be used during development. -
npm run dev
: Builds the assets once. You should run this command now.
Before you can start using or developing BIIGLE, you need to create the first user with:
docker compose exec app php artisan user:new
Follow these steps to create a new project and volume with test images:
-
Create a new directory containing a few images in the
storage/images
directory. Example:storage/images/test
. -
Open BIIGLE at http://localhost:8000 in the browser.
-
Create a new project and volume in BIIGLE. Choose "Storage disk" as volume file source and you should be able to select the directory with images created before.
Now BIIGLE is up and running and you can start developing! As a first step, you can get familiar with the Laravel directory structure.
The test files are located in tests/php
. You can run the tests with composer test
. The first time might fail since the testing database container needs to start up. To run only a subset of the tests, use composer testf <pattern>
with <pattern>
being a string that matches the test class or function that you want to run.
Static analysis for PHP can be run with composer lint
and for JavaScript with npm run lint
. These checks must pass before a pull request is accepted. In addition to that, you can fix PHP coding style issues with composer fix
.
The BIIGLE modules are installed by Composer and located in the vendor/biigle/
directory. As you have used the dev-modules
branch, they should be there already. The modules are installed as Git repositories. This allows you to modify and develop a module right in its vendor/biigle/<name>/
directory, commit and push the changes, all while you see the changes instantly applied in the running development instance.
-
To be able to contribute code changes to an existing BIIGLE module, you have to fork it first. Do this on the GitHub repository page of the module. Example: fork
biigle/annotations
to<username>/annotations
(replace<username>
with your GitHub username). -
Connect the installed module with your fork. Example: navigate to
vendor/biigle/annotations
and execute:git remote set-url origin git@github.com:<username>/annotations.git git remote set-url --push origin git@github.com:<username>/annotations.git
-
Run
git push
to check if everything worked. -
Install JavaScript dependencies of the module:
npm install
Now you can build the JavaScript dependencies with the npm run dev
command. Use npm run watch
to continuously monitor and build the files while you develop. Before you commit, run npm run prod
to commit only the minified versions of the JavaScript files and npm run lint
to check for errors.
Once you are finished with your implementation and want to propose it to be merged into the official BIIGLE module, create a pull request.
Learn more on module development and how to create a new module in the biigle/module template repository.
New Docker images are automatically built and released by the release action whenever a new (stable) release is published on GitHub.