|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +declare(strict_types=1); |
| 4 | + |
3 | 5 | namespace Hypernode\DeployConfiguration; |
4 | 6 |
|
5 | 7 | use function Deployer\after; |
6 | 8 | use function Deployer\run; |
7 | 9 | use function Deployer\task; |
| 10 | +use function Deployer\test; |
8 | 11 |
|
9 | 12 | $DOCKER_HOST = '172.17.0.2'; |
10 | 13 | $DOCKER_WEBROOT = sprintf('/data/web/apps/%s/current/pub', $DOCKER_HOST); |
11 | 14 |
|
12 | 15 | # Disable the symlinking of /data/web/public because we're gonna be deploying both staging and prod on 1 Hypernode. |
13 | 16 | task('deploy:disable_public', function () { |
14 | | - run("if ! test -d /data/web/public; then unlink /data/web/public; mkdir /data/web/public; fi"); |
| 17 | + if (!test('[ -d /data/web/public ]')) { |
| 18 | + run('unlink /data/web/public'); |
| 19 | + run('mkdir -p /data/web/public'); |
| 20 | + } |
15 | 21 | run("echo 'Not used, see /data/web/apps/ instead' > /data/web/public/index.html;"); |
16 | 22 | }); |
17 | 23 |
|
18 | 24 | # Create the venv |
19 | 25 | task('python:venv:create', static function () { |
20 | | - run('mkdir -p {{release_path}}/.hypernode'); |
21 | | - run('virtualenv -p python3 {{release_path}}/.venv'); |
| 26 | + run('mkdir -p .hypernode'); |
| 27 | + run('virtualenv -p python3 .venv'); |
22 | 28 | }); |
23 | 29 |
|
24 | 30 | # Install the requirements |
25 | 31 | task('python:venv:requirements', static function () { |
26 | | - run('source {{release_path}}/.venv/bin/activate && pip install -r {{release_path}}/requirements/base.txt'); |
| 32 | + run('source .venv/bin/activate && pip install -r requirements/base.txt'); |
27 | 33 | }); |
28 | 34 |
|
29 | 35 | # Build the documentation |
30 | 36 | task('python:build_documentation', static function () { |
31 | | - run('source {{release_path}}/.venv/bin/activate && cd {{release_path}} && {{release_path}}/bin/build_docs'); |
32 | | - run('ln -s {{release_path}}/docs/_build/html {{release_path}}/pub'); |
| 37 | + run('source .venv/bin/activate && bin/build_docs'); |
| 38 | + run('ln -s docs/_build/html pub'); |
33 | 39 | }); |
34 | 40 |
|
35 | 41 | # HMV configuration for when this is running in a docker |
36 | 42 | task('deploy:hmv_docker', static function () use (&$DOCKER_HOST, &$DOCKER_WEBROOT) { |
37 | | - run(sprintf('if test -f /etc/hypernode/is_docker; then hypernode-manage-vhosts %s --disable-https --type generic-php --yes --webroot %s --default-server; fi', $DOCKER_HOST, $DOCKER_WEBROOT)); |
| 43 | + if (test('[ -f /etc/hypernode/is_docker ]')) { |
| 44 | + run(sprintf( |
| 45 | + 'hypernode-manage-vhosts %s --disable-https --type generic-php --yes --webroot %s --default-server', |
| 46 | + $DOCKER_HOST, |
| 47 | + $DOCKER_WEBROOT, |
| 48 | + )); |
| 49 | + } |
38 | 50 | }); |
39 | 51 |
|
40 | 52 | task("deploy:docs_vhost", static function () { |
41 | | - run("hypernode-manage-vhosts --https --force-https {{hostname}} --webroot {{current_path}}/{{public_folder}}"); |
| 53 | + run("hypernode-manage-vhosts --https --force-https {{hostname}} --no --webroot {{current_path}}/{{public_folder}}"); |
42 | 54 | }); |
43 | 55 |
|
44 | 56 | $configuration = new Configuration(); |
| 57 | +$configuration->addBuildTask('python:venv:create'); |
| 58 | +$configuration->addBuildTask('python:venv:requirements'); |
| 59 | +$configuration->addBuildTask('python:build_documentation'); |
45 | 60 | $configuration->addDeployTask('deploy:disable_public'); |
46 | | -$configuration->addDeployTask('python:venv:create'); |
47 | | -$configuration->addDeployTask('python:venv:requirements'); |
48 | | -$configuration->addDeployTask('python:build_documentation'); |
49 | 61 | $configuration->addDeployTask('deploy:hmv_docker'); |
50 | 62 | $configuration->addDeployTask('deploy:docs_vhost'); |
51 | 63 |
|
|
54 | 66 | './.git', |
55 | 67 | './.github', |
56 | 68 | './deploy.php', |
57 | | - './.gitlab-ci.yml', |
58 | | - './Jenkinsfile', |
| 69 | + './.pre-commit-config.yaml', |
| 70 | + './documentation_urls.txt', |
| 71 | + './tox.ini', |
59 | 72 | '.DS_Store', |
60 | 73 | '.idea', |
61 | 74 | '.gitignore', |
62 | 75 | '.editorconfig', |
63 | | - 'etc/' |
| 76 | + 'etc/', |
| 77 | + '.venv/', |
| 78 | + 'bin/', |
| 79 | + 'hypernode/', |
| 80 | + 'requirements/', |
| 81 | + 'tests/' |
64 | 82 | ]); |
65 | 83 |
|
| 84 | +$productionStage = $configuration->addStage('production', 'docs.hypernode.io'); |
| 85 | +$productionStage->addServer('docs.hypernode.io'); |
| 86 | + |
66 | 87 | # We can also deploy to a Hypernode Docker instance. To do that you go to |
67 | 88 | # https://github.com/byteinternet/hypernode-docker, make sure you |
68 | 89 | # have an instance running by for example doing: |
|
0 commit comments