-
Notifications
You must be signed in to change notification settings - Fork 3
Development
github-actions[bot] edited this page Dec 4, 2024
·
4 revisions
The development environment uses Laravel Sail, a containerized environment with a script and easy-to-use commands for interacting with it.
Copy .env.example
to .env
:
cp .env.example .env
After doing so, update the values only as needed. The important ones that will most likely need to be filled in are the ConCat and Telegram items.
- Create a ConCat account on your ConCat instance for OAuth and ensure it has developer authorization.
- Add a new OAuth App at Housekeeping -> Developers -> OAuth Applications -> Create New
- Use
http://localhost
for the callback URL - Select the
registration:read
andvolunteer:read
application permissions
- Use
- Update
CONCAT_CLIENT_SECRET
andCONCAT_CLIENT_ID
in.env
- Create a bot via @BotFather (
/newbot
) - Update
TELEGRAM_BOT_TOKEN
in.env
- Install the PHP CLI for your environment (ex:
sudo apt install php-cli
) - Install Composer
- Run
composer install
in the application directory -
(Optional) Add
sail
alias withalias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'
- It would probably be a good idea to add this to your shell startup script (ex:
~/.bashrc
)
- It would probably be a good idea to add this to your shell startup script (ex:
Whenever using a Sail command, if you don't have an alias setup, use sh vendor/bin/sail
instead of sail
.
- To run the container, use
sail up
(Ctrl+C to stop) -
If this is the first time the env has been run:
- Run
sail artisan key:generate
(UpdatesAPP_KEY
in.env
) - Run
sail npm install
- Initialize the database schema with
sail artisan migrate
-
(Optional) Seed the database with dummy accounts with
sail artisan db:seed
- Run
- To run the Vite server, use
sail npm run dev
(Ctrl+C to stop) - Open the project on http://localhost (it may be slow)
- If you see an Apache/nginx/etc. splash screen, ensure you don't already have a web server bound to port 80.
- Using
php artisan tinker
orsail artisan tinker
will present a PHP REPL with the application bootstrapped, allowing you to mess with any part of the application and see the result of code in real-time. See the Artisan documentation for more information. - The helpers
dump(...)
anddd(...)
can be extremely helpful for debugging the application. The former pretty-prints a representation of any data passed to it with full HTML formatting, and the latter does the same but also immediately halts further execution of the application. Collections and Carbon instances also have->dump()
and->dd()
methods. - Use
php artisan make:migration
orsail artisan make:migration
to create a new database migration. See the migrations documentation for more information. - The Laravel documentation and API documentation will be very helpful if you're not already familiar with the framework.
- Running
composer run format
andnpm run format
will format all PHP and JavaScript code, respectively. - Running
npm run lint
will lint all JavaScript code, checking for common errors and making recommendations.-
npm run lint:fix
will automatically apply fixes for many of these. -
npm run lint:fix-unsafe
will correct even more, but these changes should be manually verified.
-
- Clone this repository whereever you will be building/running the Docker containers
- Copy all of the
*.env.example
files in.docker/
to just*.env
(in the same directory)..docker/
should haveapp.env
,certbot.env
,nginx.env
,postgres.env
, andredis.env
. - Modify the
.env
files in.docker/
for your configuration. Specifically, you should ensure the following keys are updated at the very least:-
app.env:
APP_KEY
,APP_URL
,DB_PASSWORD
,REDIS_PASSWORD
,CONCAT_CLIENT_ID
,CONCAT_CLIENT_SECRET
,TELEGRAM_BOT_TOKEN
(see details in the development section for the ConCat and Telegram config keys, as well as for generating a key forAPP_KEY
the first time)- For the
APP_KEY
value, this is the encryption key used for all reversible encryption in the application. This is typically generated by thephp artisan key:generate
command, but running this requires PHP setup locally, which may not always be desireable. The key itself is a base64-encoded string of 32 bytes of entirely random data when using the AES-256-CBC cipher (default). You can easily generate this yourself
- For the
-
certbot.env:
LETSENCRYPT_DOMAIN
,LETSENCRYPT_EMAIL
,LETSENCRYPT_DRY_RUN
(clear the value for this once confirmed working) -
nginx.env:
NGINX_HOST
-
postgres.env:
POSTGRES_PASSWORD
(should matchDB_PASSWORD
inapp.env
) -
redis.env:
REDIS_PASSWORD
(should matchREDIS_PASSWORD
inapp.env
)
-
app.env:
- Run
docker compose -f docker-compose.prod.yml build
to build the necessary (app and nginx) images - Run
docker compose -f docker-compose.prod.yml up -d
to run the images in the Docker daemon - Once everything has started up, the application will not yet be functional if it's the first time running.
Follow these steps once the containers are up:
- Run
docker compose -f docker-compose.prod.yml exec app php artisan migrate
to run migrations on the database - Wait for output from certbot in
docker compose -f docker-compose.prod.yml logs certbot
to confirm that the dry-run succeeded - Clear the value for
CERTBOT_DRY_RUN
in certbot.env - Run
docker compose -f docker-compose.prod.yml restart certbot
- Log in to Tracker to make sure a user is created for you
- Run
docker compose -f docker-compose.prod.yml exec app php artisan auth:set-role
to set your user's role to admin
- Run