New Project Setup
Git
If you're copying an existing application, use GitHub's "Use this template" feature. Read more here.
Create a repository on our organization on GitHub using the naming rules below.
In the GitHub project's settings, uncheck the features "Wikis", "Issues" and "Projects".
In branches settings, make sure your permanent branches are protected (usually only master
) and make sure
the base branch is master
.
The Protect matching branches settings should be:
- Require pull request reviews before merging
- Require approvals
- Require status checks to pass before merging
Repository naming conventions
The name should reflect the identification of the system or site with preferably a single word and it must be kebab-cased.
- Bad:
LaravelBackup
,Spoon
, 'guidelines.adaptive.nu` - Good:
laravel-backup
,spoon
,guidelines
Domain naming conventions
We preferably don't use www
as a subdomain.
- Bad:
https://www.adaptivemedia.se
- Good:
https://adaptivemedia.se
,https://dora.onlyapps.se
For staging/qa environments, use the environment as the prefix. This way the environment is always first no matter if it's a TLD or not.
- Bad:
dora-staging.onlyapps.se
,staging-exim.se
- Good:
staging-dora.onlyapps.se
,staging.exim.se
Server
This only applies if you're creating a new server, some sites can be placed on an existing server.
1. Create a new server at Glesys:
- Type: KVM
- Template: Ubuntu >= 22.04, 64-bit
- Datacenter: Stockholm
- Bandwidth: >= 100 Mbit
Make sure the hostname is easily identifiable (system, service, purpose, env etc), eg:
Only prod
- workfox
Only dev & prod
- workfox-dev
- workfox-prod
Web & db separated with dev & prod
- workfox-dev-web
- workfox-dev-db
- workfox-prod-web
- workfox-prod-db
- Staging + qa combined
-
- workfox-staging-qa
2. Create the server in forge
- Create a custom VPS. Make sure that the hostname matches.
- Log in to the server:
ssh user@{ip}
and run the install script (as sudo) Forge gives you and wait for it do finish. - Go to the
PHP
tab in Forge and update values and enable OPCache. - Create a new site with root
/public
(or/current/public
if using Envoyer) - Goto the servers
Database
tab and create a new user & database for this project with the same user as database name (eg.uptimer
). Don't forget to add this info to 1p. - (If not using Envoyer) Update the relevant
.env
variables. Don't forget to add the necessary service API keys later.
2.5 (Optionally) Setup Envoyer
- Create a new project in Envoyer
- Add the new server with the "Import from Forge" button
- Check that a connection can be made by clicking the refresh icon under "Connection status"
- If a connection can't be made, add Envoyer's SSH-key to Forge manually by clicking on the 🗝 icon in Envoyer and pasting it to Forge's "SSH Keys" tab
- Copy hooks from another similar project (don't forget to edit the hooks and apply them to the server!)
- Add
.env
credentials (easiest is to just copy it from your local project and changing necessary variables) - Deploy
3. Configure the server (date, php/nginx conf etc)
- Run the Recipe in Forge called "Conf PHP/nginx" (if not done on creation) which will:
- Configure php-fpm and nginx proxy timeout
- Set
memory_limit = 512M
in php.ini - Set
date.timezone = Europe/Sinckholm
in php.ini - Set
max_execution_time = 300
in php.ini - Set
upload_max_filesize = 10M
in php.ini - Set
post_max_size = 10M
in php.ini
- Set the servers timezone in Forge to
Europe/Stockholm
Setup email sending service
Setup Bug tracker (Sentry)
For all new projects, we use Flareapp.
Each environment should have its own project in Flareapp. This way we can separate errors between environments.
Continuous Integration (CI)
Set up checks for code quality and style compliance using the Continuous Integration (CI) guide.