dd61ee44c5
### 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>
33 lines
786 B
YAML
33 lines
786 B
YAML
version: '3'
|
|
|
|
services:
|
|
next-app:
|
|
container_name: next-app
|
|
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
|
|
restart: always
|
|
ports:
|
|
- 3000:3000
|
|
networks:
|
|
- my_network
|
|
|
|
# Add more containers below (nginx, postgres, etc.)
|
|
|
|
# Define a network, which allows containers to communicate
|
|
# with each other, by using their container name as a hostname
|
|
networks:
|
|
my_network:
|
|
external: true
|