This project is currently in very early development. For information on the purpose of Habitat, read the blog post.
Fork this repository to create your own instance of Habitat. To adhere to the AGPL license, your fork must be a public repository, so be careful not to ever commit any secrets to your fork.
The packages and setup required for hosting Habitat on a Linux server are in the Ansible playbook.
Install ansible and the collections:
ansible-galaxy collection install community.general
ansible-galaxy collection install community.mysql
To run the ansible playbook:
- Navigate to the
Ansible
directory - Copy
vars.yaml.template
tovars.yaml
and amend its contents accordingly - Run
ansible-playbook -i "domain-or-ip-address.example.com," -u example-user playbook.yaml --key-file=~/.ssh/example-key
- Set the
repository
setting inApp/deploy.php
to your fork of Habitat - Update the
host
entry inApp/deploy.php
accordingly - Run
vendor/bin/dep deploy
- Run
vendor/bin/dep database:migrate
Habitat can be setup to run on a container hosting service (Such as Google Cloud Run).
When hosting Habitat using the Dockerfile container, you'll need to connect it to:
- A volume at
/var/www/uploads/
for persistent image storage - A database which will be connected to with an environment variable
- A mail service for sending out emails
Many container hosting services offer continous deployment so that any changes to your fork of the Habitat repository automatically get deployed.
To do so, ensure that the hosting service uses the following settings:
Setting | Value |
---|---|
Branch | main |
Build type | Dockerfile |
Dockerfile location | /Dockerfile |
Setting | Value |
---|---|
Container port | 80 |
You'll need to attach a volume for image storage. If using cloud hosting, it's recommended to use a storage bucket, such as Google Cloud Storage or Amazon S3.
Setting | Value |
---|---|
Mount path | /var/www/uploads |
You'll need to set environment variables to allow the connection of a database and email handler. If using Google Cloud hosting, you can use the Google Cloud SQL service for the database, and if using AWS, you could use AWS RDS. For email handling, Mailjet have a free tier that should be enough for most Habitat isntances.
Name | Value |
---|---|
DATABASE_URL | mysql://dbUsername:dbPassword@localhost:3306/example-db-name?unix_socket=/cloudsql/example:database-instance:connection-name&serverVersion=8.0.31&charset=utf8mb4 |
MAILER_DSN | smtp://example:example@example.com:587 |
APP_ENV | prod |
ENCRYPTION_KEY | (Generate an encryption key*) |
There are online key generators. It is recommended that the encryption key is no fewer than 32 characters, consists of uppercase, lowercase, numeric and special characters.
- Navigate to the
Docker/dev
directory and copy the.env.dist
file to create a new file called.env
- Run
docker-compose up
Run any application, symfony and composer commands from within the habitat-apache-php
container:
docker exec -it habitat-apache-php bash
Habitat can be loaded in the web browser from localhost.
Cron tasks do not run automatically for local development environments. You can run them manually from within the
habitat-apache-php
container with the following command:
php /var/www/html/bin/console habitat:data-retention