Skip to content

Conversation

slashrsm
Copy link
Contributor

Based on discussion in drupal-docker/php#46.

Fixes #6.

Copy link
Member

@zaporylie zaporylie left a comment

Choose a reason for hiding this comment

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

I like sed-based approach. Have some doubts though about naming convention and entrypoint usage. Added some inline comments to place it in the context.

Just created pull request to your fork-branch with my suggestions. Curious to hear your opinion :)

Thank you for your involvement and pushing this long-standing issue forward.

@@ -11,3 +11,6 @@ RUN addgroup -g 82 -S www-data \

COPY nginx.conf /etc/nginx/nginx.conf
COPY drupal.conf /etc/nginx/conf.d/default.conf

COPY entrypoint.sh /usr/local/bin/
CMD "entrypoint.sh"
Copy link
Member

Choose a reason for hiding this comment

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

Should use ENTRYPOINT instruction

@@ -1,5 +1,5 @@
server {
server_name _;
server_name SERVER_NAME;
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need it?

@@ -1,5 +1,5 @@
server {
server_name _;
server_name SERVER_NAME;
root /var/www/html;
Copy link
Member

Choose a reason for hiding this comment

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

IMHO we should tokenize root as well. I suggest name nginx independent so I could implement it the same way in drupal-docker/apache (maybe DOCROOT).

root DOCROOT

Probably even better to use before/after special char, something like %SERVER_NAME% and %DOCROOT%

set -e

# Configure docroot.
if [ -n "$NGINX_DOCROOT" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

As I have mentioned before, this variable should be nginx independent. Maybe just DOCROOT?

sed -i 's/SERVER_NAME/'"${NGINX_SERVER_NAME}"'/' /etc/nginx/conf.d/*.conf
echo "Configured nginx server name to ${NGINX_SERVER_NAME}."

exec nginx -g "daemon off;"
Copy link
Member

Choose a reason for hiding this comment

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

@@ -11,3 +11,6 @@ RUN addgroup -g 82 -S www-data \

COPY nginx.conf /etc/nginx/nginx.conf
COPY drupal.conf /etc/nginx/conf.d/default.conf

Copy link
Member

Choose a reason for hiding this comment

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

Environment variables should be declared in Dockerfile.

@slashrsm
Copy link
Contributor Author

Makes sense. It your PR you didn't use replacement tokens with special characters as you mentioned in one of the comments. Should we do that?

Thank you for helping. I am constantly learning when contributing to this project.

@zaporylie
Copy link
Member

Yes, I think we should. As we use sed to change all the config files containing SERVER_NAME or DOCROOT (not just default.conf) we should make sure we replace only tokens which suppose to be replaced, not all occurrences of SERVER_NAME and DOCROOT string.

Still not sure why you suggested changing default server_name from _ to drupal? Probably both would work by default but IMHO _ should be used for catch-all server as it is quite common practice (ref. http://nginx.org/en/docs/http/server_names.html).

@slashrsm
Copy link
Contributor Author

Yes, I think we should. As we use sed to change all the config files containing SERVER_NAME or DOCROOT (not just default.conf) we should make sure we replace only tokens which suppose to be replaced, not all occurrences of SERVER_NAME and DOCROOT string.

Done

Still not sure why you suggested changing default server_name from _ to drupal? Probably both would work by default but IMHO _ should be used for catch-all server as it is quite common practice (ref. http://nginx.org/en/docs/http/server_names.html).

Not really sure about that. Reverted back to "_" while still offering to override it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants