Open
Description
Hey there! 👋
We're using this image (phusion/passenger-ruby25:1.0.5
) to run a Rails app, and we are not seeing the behavior documented at https://github.com/phusion/passenger-docker#setting-environment-variables-in-nginx. Environment variables that are set up through Docker Compose .env mechanism are visible to the Rails app.
My question is:
- if this expected? If so, should the documentation be updated? (happy to submit a PR)
- otherwise, should this be fixed?
My biggest concern is that this is fixed inadvertently in a further version, and apps suddenly start breaking for obscure reasons when updating the Phusion Passenger image version.
Reproduction steps
We are using docker-compose. Here are relevant extracts and reproduction steps:
# docker-compose.yml:
services:
app:
build: .
environment:
TEST_ENV_VAR: ${TEST_ENV_VAR}
# .env
TEST_ENV_VAR=test1234
# Dockerfile:
FROM phusion/passenger-ruby25:1.0.5
# Allow nginx to pass environment variables to the app at runtime:
COPY ./docker/env.conf /etc/nginx/main.d/env.conf
# [...] Copy the app's files, install dependencies, etc.
env.conf
does not contain any line like env TEST_ENV_VAR;
, yet the following is possible:
$ sudo docker-compose build
$ sudo docker-compose up -d
$ sudo docker-compose exec app bash
# The environment variable is in the container's environment:
root@c4503f22222e:/home/app# printenv | grep TEST_ENV_VAR
TEST_ENV_VAR=test1234
# Our nginx config doesn't contain anything to pass the env var to the child processes:
root@c4503f22222e:/home/app# cat /etc/nginx/main.d/db-env.conf | grep TEST_ENV_VAR
# Yet Rails has loaded the environment variable:
root@c4503f22222e:/home/app# cd webapp/
root@c4503f22222e:/home/app/webapp# bin/rails c
Running via Spring preloader in process 3004
Loading production environment (Rails 5.2.0)
2.5.1 :001 > ENV['TEST_ENV_VAR']
=> "test1234"
Metadata
Metadata
Assignees
Labels
No labels