I’m deploying my Django app using AWS code pipeline which is dockerized and I was storing my env variables inside an env file for local development but for the code pipeline I set them all inside environment variables but the variables are still getting None
.
docker-compose.yml
version: "3.8"
services:
db:
container_name: db
image: "postgres"
restart: always
volumes:
- postgres-data:/var/lib/postgresql/data/
app:
container_name: app
build:
context: .
restart: always
volumes:
- static-data:/vol/web
depends_on:
- db
proxy:
container_name: proxy
build:
context: ./proxy
restart: always
depends_on:
- app
ports:
- 80:8000
volumes:
- static-data:/vol/static
volumes:
postgres-data:
static-data:
getting env variable in django like:
os.environ.get('FRONTEND_URL')
2
Answers
in my case, I put all env variables inside my AWS CodeBuild environment variables and call them in my docker environment as below.
You can specify the env file in the docker compose itself along with relative path.
Refer more details at documentation