Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
improve exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
Web Summer Camp 2016 committed Sep 5, 2016
1 parent a551ba6 commit cbffc29
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 21 deletions.
2 changes: 2 additions & 0 deletions config/varnish/ez54.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ backend ezpublish {
acl invalidators {
"127.0.0.1";
"172.18.0.0"/24;
"172.19.0.0"/24;
//"192.168.1.0"/16;
}

Expand All @@ -30,6 +31,7 @@ acl debuggers {
// ACL for the proxies in front of Varnish (e.g. Nginx terminating https) - only other containers
acl proxies {
"172.18.0.0"/24;
"172.19.0.0"/24;
}

// Called at the beginning of a request, after the complete request has been received
Expand Down
12 changes: 9 additions & 3 deletions docs/exercises/1_handling_the_docker_stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ Question: which Symfony environment is being used?
### Set the new stack to use a different Symfony environment

cd deploy_qa
printf "\nSYMFONY_ENV=uat\n" >> docker-compose.env.local
printf "\nSYMFONY_ENV_NOVARNISH=uat\n" >> docker-compose.env.local
printf "\nSYMFONY_ENV=uat\n" >> docker-compose.env.local

Optional: give the stack a different name, to avoid confusion
Give the stack a different name, to avoid confusion

sed -i 's/COMPOSE_PROJECT_NAME=ezdeploy/COMPOSE_PROJECT_NAME=ezdeployqa/g' docker-compose.conf.sh
sed -i 's/COMPOSE_PROJECT_NAME=ezdeploy$/COMPOSE_PROJECT_NAME=ezdeployqa/g' docker-compose.conf.sh

### (Re)build and start the stack

Expand All @@ -87,11 +88,13 @@ Check that it is working:

NB: this has to be done *from within the cli container*

docker exec -ti ezdeploy_cli su site
docker exec -ti ezdeployqa_cli su site

# (in the container)
# edit line 22, replace 'dev' by 'uat'
sed -i 's/ENVIRONMENT=dev/ENVIRONMENT=uat/g' web/.htaccess
# edit line 22, disable usage of Assetic debug mode
sed -i 's/SetEnvIf Request_Method .* USE_DEBUGGING=1/SetEnvIf Request_Method .* USE_DEBUGGING=0/g' web/.htaccess
# exit the container
exit

Expand All @@ -111,6 +114,9 @@ What has happened ?
# patch them
sed -i 's/parameters_dev.yml/parameters_uat.yml/g' config_uat.yml
sed -i 's/routing_dev/routing_uat/g' config_uat.yml
# disable Sf debug mode tools
sed -i 's/web_profiler:/#web_profiler:/g' config_uat.yml
sed -i 's/ toolbar:/# toolbar:/g' config_uat.yml
sed -i 's/ intercept_redirects:/# intercept_redirects:/g' config_uat.yml

Test against access to http://deploy.websc/ and http://deploy.websc/ezdeploy_site_admin
2 changes: 1 addition & 1 deletion docs/exercises/2_managing_legacy_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Prerequisites: having created the 'uat' docker stack (exercise 1); having it run
### Deploy them

NB: this has to be done *from within the cli container*
docker exec -ti ezdeploy_cli su site
docker exec -ti ezdeployqa_cli su site

# (in the container)
# deploy the settings
Expand Down
4 changes: 3 additions & 1 deletion docs/exercises/3_managing_custom_configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ Prerequisites: having created the 'uat' docker stack (exercise 1); having it run
cp dev/web/.htaccess uat/web
sed -i 's/ENVIRONMENT=dev/ENVIRONMENT=uat/g' uat/web/.htaccess
sed -i 's/ENVIRONMENT=uat/ENVIRONMENT=dev/g' dev/web/.htaccess
sed -i 's/SetEnvIf Request_Method .* USE_DEBUGGING=1/SetEnvIf Request_Method .* USE_DEBUGGING=0/g' uat/web/.htaccess
sed -i 's/SetEnvIf Request_Method .* USE_DEBUGGING=0/SetEnvIf Request_Method .* USE_DEBUGGING=1/g' dev/web/.htaccess

### Deploy them

NB: this has to be done *from within the cli container*
docker exec -ti ezdeploy_cli su site
docker exec -ti ezdeployqa_cli su site

# (in the container)
# deploy the config files
Expand Down
2 changes: 1 addition & 1 deletion docs/exercises/4_dump_and_reload_db.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Optional: log in to the admin interface and change the name of a content, to be
cd /var/www/summercamp/workshops/deploy_qa
php stack.php run

docker exec -ti ezdeploy_cli su site
docker exec -ti ezdeployqa_cli su site
NB: this has to be done *from within the cli container*
./bin/importdb.sh
# exit the container
Expand Down
11 changes: 7 additions & 4 deletions docs/exercises/5_db_migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Goal of the exercise: learn how to use Migrations to manage changes to the conte

Prerequisites: having created the 'uat' docker stack (exercise 1); having it running

## Task 1: add an attribute of type 'image' to the 'article' class
## Task 1: add an attribute of type 'image' to the 'folder' class

cd /var/www/summercamp/workshops/deploy_qa
docker exec -ti ezdeploy_cli su site
docker exec -ti ezdeployqa_cli su site
NB: this has to be done *from within the cli container*
php ezpublish/console kaliop:migration:generate WebSCSampleBundle

Expand All @@ -24,10 +24,13 @@ Replace the contents with the following YML (take care about indentation):
identifier: image
type: ezimage
name: Image
description: Just an Image
description: Just an Image

Execute the migration: from within the cli container

php ezpublish/console kaliop:migration:migrate
php ezpublish/console kaliop:migration:migrate

# exit the container
exit

Connect to http://deploy.websc/ezdeploy_site_admin and check that the Folder class has been modified
7 changes: 5 additions & 2 deletions docs/exercises/6_deployment_script.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ Prerequisites: having created the 'uat' docker stack (exercise 1); having it run
cd /var/www/summercamp/workshops/deploy_qa

NB: this has to be done *from within the cli container*
docker exec -ti ezdeploy_cli su site
docker exec -ti ezdeployqa_cli su site

# (in the container)
# (in the container)
./bin/deploy.sh

Look at the output on screen and try to make sense of it

# exit the container
exit
4 changes: 2 additions & 2 deletions docs/exercises/7_adding_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Prerequisites:
## Task 1: run a phpunit test to check if the migration was executed correctly

cd /var/www/summercamp/workshops/deploy_qa
docker exec -ti ezdeploy_cli su site
NB: this has to be done *from within the cli container*
docker exec -ti ezdeployqa_cli su site
# NB: this has to be done *from within the cli container*
./bin/phpunit src/WebSC/SampleBundle/Tests/PHPUnit/

Question: what has just happened?
Expand Down
2 changes: 1 addition & 1 deletion images/web/bootstrap.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ echo [`date`] Modifying Apache configuration...
SYMFONY_ENV_TRUSTEDPROXIES=$(ping -c1 -n varnish 2>/dev/null | head -n1 | sed "s/.*(\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)).*/\1/g")
if [ "$SYMFONY_ENV_TRUSTEDPROXIES" = "" ]; then
# @todo move this to a config var, as we currently get 172.21.0.6...
SYMFONY_ENV_TRUSTEDPROXIES=172.18.0.0/24
SYMFONY_ENV_TRUSTEDPROXIES=172.18.0.0/24,172.19.0.0/24
fi

# @todo improve this: if the container is bootstrapped many times, the envvars file will keep growing
Expand Down
4 changes: 2 additions & 2 deletions site/bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ php $DIR/ezp5installer.php memcache:purge

# purge varnish (based on env settings)
echo "Purging varnish..."
if [ "dev" = "$ENV" ]; then
# when deploying the 'dev' env, we clear varnish for the 'demo' env, as they run both on the same installation
if [ "dev" = "$ENV" or "uat" = "$ENV" ]; then
# when deploying the 'dev' envs, we clear varnish for the 'demo' env, as they run both on the same installation
php $DIR/ezp5installer.php varnish:purge --key=ezpublish.system.ezdeploy_site_group.http_cache.purge_servers --env=demo
else
php $DIR/ezp5installer.php varnish:purge --key=ezpublish.system.ezdeploy_site_group.http_cache.purge_servers
Expand Down
4 changes: 2 additions & 2 deletions site/ezpublish/env_files/dev/web/.htaccess
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### htaccess for DEV env

# Allow ONLY TRUSTED IPS to send calls to clean the OPCache
RewriteCond %{REMOTE_ADDR} ^172\.18\.0\.
# Allow ONLY TRUSTED IPS to send calls to clean the OPCache. This seems to change with Docker versions...
RewriteCond %{REMOTE_ADDR} ^172\.1[89]\.0\.
RewriteRule ^clearopcache.php - [L]

# NB: we have to leave out the indented ones and set them in the vhost config
Expand Down
8 changes: 6 additions & 2 deletions site/src/WebSC/SampleBundle/Tests/PHPUnit/2_RoutingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ public function testRouteIsAvailable($url)
{
$client = new Client();
$request = $client->get($this->getHostName() . $url);
$response = $client->send($request);
$this->assertEquals(200, $response->getStatusCode());
try {
$response = $client->send($request);
$this->assertEquals(200, $response->getStatusCode());
} catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) {
$this->fail($e->getMessage());
}
}

public function urlProvider()
Expand Down

0 comments on commit cbffc29

Please sign in to comment.