If configured correctly, you only need to git push origin master
.
Jenkins in ci.nfqakademija.lt
will run:
$WORKSPACE/.deploy/build.sh
echo "[app]
nfqakademija.lt ansible_host=deploy.nfqakademija.lt ansible_user=$JOB_NAME
" > $WORKSPACE/.deploy/ansible_hosts
$WORKSPACE/.deploy/deploy.sh
And your page will appear in http://PROJECT_NAME.projektai.nfqakademija.lt/,
where PROJECT_NAME
is usually the same as the name of github repository.
- You merge your changes to
master
branch and push it to GitHub (git push origin master
) - GitHub have WebHook configured for the project, so it informs
ci.nfqakademija.lt
, that new changes are pushed to repository (this is optional step just make deployment faster and easier) - Jenkins checks if it have triggers enabled and branch is
master
– if all ok, Jenkins starts new job. Meaning, it executesbuild.sh
, generatesansible_hosts
file and executesdeploy.sh
. (you can trigger build manually by logging in toci.nfqakademija.lt
and pushingBuild Now
) - Ansible (started by
deploy.sh
) use configuration indeploy_playbook.yaml
. Usually it SSH to Web Server, copies build artifacts (E.g.project.tar.gz
), change symbolic links to newest version (to make deployment atomic), warm-up cache. - If there are no errors, you should see your new changes via
http://PROJECT_NAME.projektai.nfqakademija.lt/
, wherePROJECT_NAME
is your GitHub repository name. - For more complex scenarios (E.g. custom
.env
configuration, setting up database tables), you can connect to WEB server usingssh [email protected] -p 2222
, wherePROJECT_NAME
is your GitHub repository name. - If there are any errors, you can login to ci.nfqakademija.lt and in
Build History
checkConsole Output
. Last lines usually shows error message. Whole output is generated bybuild.sh
anddeploy.sh
commands. (E.g. you can see+ composer install --no-dev --no-scripts --no-interaction --optimize-autoloader
command).
To get notifications about failed/successful builds, you can add Jenkins
integration to Slack
- ❗ Do not add passwords to
.env
file – because it will be pushed publickly to GitHub - During development put real values in
.env.local
– so they would be kept only in your machine - Use
ssh [email protected] -p 2222
to connect to production server:nano ~/shared/.env.local
to update files manually on a server
For mail configuration. We recomend using Gmail:
.env
would be used for documentation only. E.g.:
MAILER_URL=null://localhost
.env.local
use real value specific to your machine or production server. E.g.:
MAILER_URL=gmail://username:password@localhost
- SSH to deploy server:
ssh [email protected] -p 2222
Where PROEJCT_NAME
is your GitHub repository name
- Go to current deployed version
cd ~/current
- Use
bin/console
as you did locally (database credentials already in.env
, which is linked to~/shared/.env
):
bin/console doctrine:migrations:migrate
Answer Yes
(assuming you are the author and know, what migrations are to be applied)
If you see white/blank page. It may be related to errors in your PHP application. To debug:
- SSH to deploy server:
ssh [email protected] -p 2222
Where PROEJCT_NAME
is your GitHub repository name
- Check PHP-FPM/nginix logs
tail -f /var/log/php7.3-fpm.log | grep "pool $USER"
You should see somehting like:
[27-Oct-2019 19:40:45] WARNING: [pool test20191027] child 9131 said into stderr: "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test20191027.test' doesn't exist" at ... Driver/AbstractMySQLDriver.php line 42"
If that does not help. You can temporary set APP_ENV=dev
in ~/current/.env.local
. But this is last option and is not good practice.
- Check Symfony logs
tail ~/current/var/log/prod.log
You could see something like:
[2019-04-24 15:22:56] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\TableNotFoundException: "... doesn't exist at ... /vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117)"} []
- Check, if all migrations are exectuted
~/current/bin/console doctrine:migrations:status
More inforamtion at doctrine docs