Hello Fellas,
I am working on a project that uses elixir 1.9 and phoenix 1.5.7 in an ubrella project.
Now in certain live views I need to access enviroment variables which I normally do through
System.get_env("AWS_BUCKET_NAME_IE")
The problem is that when I deploye through docker the variables that suppose to containing enviroment variable content are empty.
But wierdly enough (at least for me) if I log into the container. through
- docker exec -it {container_name} bash
- ./bin/appname remote
If I try to access the variable from the elixir shell I got, for example executing System.get_env("AWS_BUCKET_NAME_IE")
I get the expected results
The way I ussyally get the name of the variables in the live_view is
@bucket System.get_env("AWS_BUCKET_NAME_IE")
and that always has an empty string as result when deploying with docker.
my Docker file looks like (app specific names are changed)
FROM bitwalker/alpine-elixir-phoenix:latest as builder
WORKDIR /app
ENV MIX_ENV=prod \
SECRET_KEY_BASE=$SECRET_KEY_BASE \
AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
AWS_BUCKET_NAME=$AWS_BUCKET_NAME \
AWS_ASSETS_BUCKET_NAME=$AWS_ASSETS_BUCKET_NAME \
DATABASE_URL=$DATABASE_URL \
SHELL=/bin/bash
# install hex + rebar
RUN mix do local.hex --force, local.rebar --force
COPY config config
COPY mix.* ./
COPY apps/app/mix.exs ./apps/app/
COPY apps/app_web/mix.exs ./apps/app_web/
RUN mix do deps.get --only $MIX_ENV, deps.compile
COPY . /app/
# build assets
WORKDIR /app/apps/app_web
RUN npm install --prefix ./assets/ ci --progress=false --no-audit --loglevel=error
RUN npm run deploy --prefix ./assets
RUN mix phx.digest
WORKDIR /app
RUN PORT=4000 MIX_ENV=prod mix do compile, phx.swagger.generate, release
# prepare release image
FROM bitwalker/alpine-elixir:1.10.3
ARG VERSION=0.7.0
WORKDIR /app
COPY --from=builder /app/_build/prod/rel/app /app/
RUN ln -s ./app/lib/app_nameapi_web-${VERSION}/priv/static /app/static
ENV HOME=/app
EXPOSE 4000
ENTRYPOINT ["./bin/app", "start"]
and then the docker-compose
services:
app:
image: eu-west-3.amazonaws.com/app/web:staging
expose:
- "4000/tcp"
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_BUCKET_NAME=${AWS_BUCKET_NAME}
- DATABASE_URL=${DATABASE_URL}
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
env_file:
- envfile
volumes:
- appweb_static_vol:/app/static
Any direction on where to look for the problem would be greatly appriciated !