docker-symfony icon indicating copy to clipboard operation
docker-symfony copied to clipboard

Use custom server name

Open milanito opened this issue 8 years ago • 10 comments

Hello,

First, let me thank you for this project.

This PR has the same goal than #68 , meaning using a custom env variable for the server name (for the moment is it symfony.dev in the config file)

Description

Nginx is not supposed to read for env variables, to do so, you need the Lua support through the dedicated module. The recommanded way to use it is to use openresty, which I did in the nginx image

Usage

A new env variable has been added to the .env.dist file, SERVER_NAME. You should update this variable to change your server name

Changes

The nginx service now uses openresty. Because Openresty does not come with default file, I had to :

  • Create dedicated config directories
  • Add fastcgi_params and mime.types files to the project

The env variables is retrieved using the set_by_lua_block directive, using this simple block :

return os.getenv("SERVER_NAME")

Related Issue

Fix #58

Misc

This PR has been tested with this demo app, which is in 3.1, and an internal application (not from auth0), which is in 3.3 .

The applications have been tested both on Mac OS X and Ubuntu.

Thank you for reading 😄

milanito avatar Nov 29 '17 10:11 milanito

Nice one here @milanito !

I'm working on an improvement to add more than one symfony apps.

I'll be waiting for your PR to be accepted to integrate your changes in my working copy.

PyRowMan avatar Jan 29 '18 14:01 PyRowMan

@PyRowMan does this PR works on your environment?

maxpou avatar Jan 31 '18 16:01 maxpou

@maxpou I did not integrated it yet for now

My docker project integration is currently in hold because our work machines are lacking some RAM; but it's planned to integrate and test it as soon as i receive the hardware :)

PyRowMan avatar Jan 31 '18 16:01 PyRowMan

cool, I'm looking forward then!

maxpou avatar Jan 31 '18 16:01 maxpou

@PyRowMan you're welcome 😄

Tell me if you have any issue, but I think you could make it run on your env.

We have been deploying a staging env for our application using this PR code, for the moment we have had no issue, but this is an env we tailored to our needs

milanito avatar Feb 01 '18 17:02 milanito

@maxpou I am too, i'm really tired of working with that shitty wampserver uU

@milanito I haven't actually even installed the PR for now, but i have seen the commit files and there is no probleme i can foresee.

Nonetheless i have a problematic that i can't solve :

At first my idea for integrating more than one app into the project was to creating a new docker container for each symfony app.

But after trying that solution I had ran into some issues.

I then got back to the temporary easy standard "all symfony apps in the same container".

So i'm asking it now: what are you thinking is the best solution ?

Btw : One of the problems with the second solution is that you can't set the workdir to the symfony app directly... And i'm annoyed with it.

PyRowMan avatar Feb 01 '18 18:02 PyRowMan

@PyRowMan I think the first solution is the one I'd use. But in this case, you might have to change several things :

  • You'd have to update your nginx configuration with a new configuration file for your new application
  • Update the nginx docker file with ADD your_new_conf.conf /etc/nginx/sites-available/ and RUN ln -s /etc/nginx/sites-available/your_new_conf.conf /etc/nginx/sites-enabled/your_new_conf
  • Update the docker compose file, by adding a new service for each application, in which the most important part is the volume one, in particular :- ${SYMFONY_APP_PATH_2}:/var/www/your_new_conf
  • Don't forget to update the volumes_from: entry for the nginx and elk volumes
  • Update the .env file with the value of SYMFONY_APP_PATH_2 (But I think it might work with the same value)

I think with all that it should work.

Anyway, I'm not sure it's the right place for this discussion 😄 maybe after this PR is merged, you could open an issue for that ?

milanito avatar Feb 02 '18 09:02 milanito

@milanito Yes, you are totally right ! I'll do that as soon as I have the time to write the right issue.

About that PR, I tested your branch yesterday, here is my review :

Note that I had activated the opcache before merging you PR.

I had less performances after merging your branch, something like 0.3 seconds more loading page on a standard symfony page.

Do you have any idea where that can come from ?

PyRowMan avatar Feb 02 '18 09:02 PyRowMan

@PyRowMan uhm, to be honest no 😄

Could you provide maybe a benchmark comparing both env (before and after the PR) ? I though it'd might be openresty but it's supposed to be even better.

milanito avatar Feb 02 '18 14:02 milanito

@milanito Today my environnement don't want to play I think. I was at like 1.5 sec loading time yesterday; today i'm at 17 sec loading time.

But when i tested it there was no real difference between the two branches. (0.3 seconds like I said)

I'll make a Issue to integrate opcache and test the perfs.

PyRowMan avatar Feb 04 '18 13:02 PyRowMan