Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why can't I use the Environment Variables when I am extending wodby/nginx ? #39

Closed
flesheater opened this issue Nov 16, 2019 · 1 comment

Comments

@flesheater
Copy link

flesheater commented Nov 16, 2019

Hi :)
First I want to say that I am absolutely loving all the containers and that you've done a wonderful job.
And second - to the question:

I want to use the wodby/nginx:1.17-5.6.8 but I want to additionally install yarn there so I thought I could use it and just extend it.
So this is what I did:
docker-compose.yml:

version: "3"
services:
  styleguide:
    build: nginx
    container_name: "${PROJECT_NAME}_page"
    environment:
      NGINX_SERVER_ROOT: /var/www/html/dist
    volumes:
      - ./:/var/www/html
    labels:
      - "traefik.http.routers.${PROJECT_NAME}_styleguide.rule=Host(`${PROJECT_BASE_URL}`)"

nginx/Dockerfile:

FROM wodby/nginx:1.17-5.6.8

RUN apk add yarn

I also have a .env file of course with the PROJECT_NAME, PROJECT_BASE_URL values.

The thig is that when I am doing it so - it builds, but the environment variable NGINX_SERVER_ROOT does not get recognized.

on the other hand if I am not extending it, but simply am doing

version: "3"
services:
  styleguide:
    image: wodby/nginx:1.17-5.6.8
    container_name: "${PROJECT_NAME}_page"
    environment:
      NGINX_SERVER_ROOT: /var/www/html/dist
    volumes:
      - ./:/var/www/html
    labels:
      - "traefik.http.routers.${PROJECT_NAME}_styleguide.rule=Host(`${PROJECT_BASE_URL}`)"

using directly the image, without re-building - it of course works.
Would you please advise me on how could I both extend, and re-use the wonderful Environment Variables of this project?

Cheers and have a nice day,
Nikolay

@csandanov
Copy link
Member

Hi, this is a generic question about how docker-compose works and has nothing to do with this image and therefore should better be asked on StackOverflow. With that being said please see notes in the documentation on environment in docker-compose https://docs.docker.com/compose/compose-file/#environment

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

No branches or pull requests

2 participants