Skip to content

Commit

Permalink
Show how to utilize the provided .env file in the docker-compose file (
Browse files Browse the repository at this point in the history
…#50712)

### What?
I added a small change to the `with-docker-compose` example to show how to make the provided `.env` file usable.

### Why?
I struggled to understand why I could not get environment variables to work as intended and thought this small change might help someone else new to docker in the future.

### How?
Added a few comments to the `docker-compose.dev.yml` file, along with showing how to utilize a `.env` file with docker-compose



Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
DustinsCode and ijjk committed Jun 14, 2023
1 parent d080c8e commit dd61ee4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/with-docker-compose/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ services:
build:
context: ./next-app
dockerfile: dev.Dockerfile

# Set environment variables directly in the docker-compose file
environment:
ENV_VARIABLE: ${ENV_VARIABLE}
NEXT_PUBLIC_ENV_VARIABLE: ${NEXT_PUBLIC_ENV_VARIABLE}

# Set envrionment variables based on the .env file
env_file:
- .env
volumes:
- ./next-app/src:/app/src
- ./next-app/public:/app/public
Expand Down

0 comments on commit dd61ee4

Please sign in to comment.