Skip to content
This repository was archived by the owner on Sep 3, 2026. It is now read-only.

EZP-27542: Add support for using Varnish with Docker - #188

Merged
andrerom merged 8 commits into
1.7from
varnish_docker
Jul 6, 2017
Merged

andrerom merged 8 commits into
1.7from
varnish_docker

Conversation

@andrerom

@andrerom andrerom commented Jun 21, 2017 •

Copy link
Copy Markdown
Contributor

Issue: https://jira.ez.no/browse/EZP-27542

Alternative try to #143.

Adds:

  • possibility to inject http cache config by env variables
  • varnish container and docker compose setup taking advantage of this
  • test it on travis using our existing behat setup
  • doc updates for this

@Plopix

Plopix commented Jun 21, 2017 •

Copy link
Copy Markdown
Contributor

Hello @andrerom,

I think this PR should be split into 2, the 3 files for the configuration injection on one side and the docker/automated test complexity on the other.

app/config/default_parameters.yml
app/config/env/docker.php
app/config/ezplatform.yml

I have a use case in PROD (no docker), on AWS where I would love to just have to:

  • change a ENV variable
  • clear the cache

Even better and more globally it will be great to use that:
http://symfony.com/blog/new-in-symfony-3-2-runtime-environment-variables

It would avoid a cache clear.

My scenario is, if for any reason I am adding a Varnish, I need to update the config of the web server.

Let me know I can PR something especially for that.

++

@andrerom

andrerom commented Jun 22, 2017 •

Copy link
Copy Markdown
Contributor Author

Even better and more globally it will be great to use that:

This is for 1.7 (symfony 2.8), implied is that it will need to be adjusted when merged into 2.0 branch where we already use env()

For the rest, I'll see if I can get the container running, if not I'll split up.

@andrerom
andrerom changed the base branch from master to 1.7 June 22, 2017 11:08
@andrerom

andrerom commented Jun 22, 2017 •

Copy link
Copy Markdown
Contributor Author

Passing 🎉

also fixed platformui profile failures caused by random Stash failures (random bug) by instead using redis for that one for now, adding some coverage for redis while at it.

Both since it randomly crashes with Stash error when directories are attempted to be deleted between tests, and to get coverage with redis.
@andrerom andrerom changed the title [WIP][Docker] Add support for using Varnish incl config injection [Docker] Add support for using Varnish incl config injection Jun 22, 2017
@andrerom
andrerom requested review from bdunogier and vidarl June 22, 2017 12:55
@andrerom

andrerom commented Jun 22, 2017 •

Copy link
Copy Markdown
Contributor Author

Ready for review

Review notes

The VCL added here is maybe something that could be part of the main one, but the difference is:

diff --git a/doc/varnish/vcl/varnish4.vcl b/doc/varnish/vcl/varnish4.vcl
index 8d743b6..7be2e95 100644
--- a/doc/varnish/vcl/varnish4.vcl
+++ b/doc/varnish/vcl/varnish4.vcl
@@ -6,20 +6,21 @@ vcl 4.0;
 // Our Backend - Assuming that web server is listening on port 80
 // Replace the host to fit your setup
 backend ezplatform {
-    .host = "127.0.0.1";
+    .host = "web";
     .port = "80";
 }
 
 // ACL for invalidators IP
 acl invalidators {
     "127.0.0.1";
-    "192.168.0.0"/16;
+    "172.16.0.0"/20;
+    "app";
 }
 
 // ACL for debuggers IP
 acl debuggers {
     "127.0.0.1";
-    "192.168.0.0"/16;
+    "172.16.0.0"/20;
 }

So it's a bit specific.

@andrerom andrerom changed the title [Docker] Add support for using Varnish incl config injection EZP-27542: Add support for using Varnish with Docker Jun 22, 2017
@andrerom
andrerom requested a review from glye June 22, 2017 19:12

@glye glye left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 FWIW, with two speling nitpicks (no longer relevant). Interesting to dig around in the intestines of this stuff.

# Use packages from Varnish to get Varnsih 5.1 which is a bit more stable then Varnsih 5.0.0 in stretch
RUN apt-get install -q -y --force-yes --no-install-recommends ca-certificates curl \
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish5/script.deb.sh | bash
# Use packages from Varnish to get Varnsih 5.1, currently does not work on debian:stretch

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Varnsih -> Varnish

apt-get install -q -y --force-yes --no-install-recommends varnish

# If we need varnish modules this is one way, or we need to find a way to install on the package above.
# This will need debian:stretch, just here for referance, had segmentation faults so rather using varnsih 5.1 above

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: varnsih -> varnish

@Plopix

Plopix commented Jun 23, 2017

Copy link
Copy Markdown
Contributor

+1 for the PR

About the Varnish config, to avoid 2 files, we could:
a). do a script like for the vhost.sh that would make the changes and we would have only one VCL. (sounds complex)
b) split the VCL in different files and define the backend in a specific file (maybe the good one)
c) directly change the main doc/varnish/vcl/varnish4.vcl, and a mention in the doc to explain.

c) is my preferred way

@andrerom

Copy link
Copy Markdown
Contributor Author

Thanks for the fixes @glye.

@Plopix I'm also fine with c) or b), but b) would bump requirement to 5.x right? @bdunogier what's your take/pref?

@Plopix

Plopix commented Jun 23, 2017

Copy link
Copy Markdown
Contributor

@andrerom include works on 4.x ;)

@andrerom

andrerom commented Jul 5, 2017

Copy link
Copy Markdown
Contributor Author

@Plopix Actually include also works on 3.x, so adapted to get rid of the vcl duplication. Ok @Plopix / @glye ?

@glye

glye commented Jul 5, 2017

Copy link
Copy Markdown
Member

👍 Red code is dead code is good code.

@Plopix

Plopix commented Jul 5, 2017

Copy link
Copy Markdown
Contributor

👍 yes that is cool!

@andrerom
andrerom merged commit 08d2e94 into 1.7 Jul 6, 2017
@andrerom
andrerom deleted the varnish_docker branch July 6, 2017 08:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants