AlexanderKim
1 month ago
1105
5
Requests

How to use docker compose's env variables inside laravel/lumen envs?

Posted 1 month ago by AlexanderKim

If i set env variables inside compose.yml:

version: '3'
services:
  branch-api:
    restart: always
    image: "imagename"
    ports:
      - 9000:80
    container_name: "branch"
    environment:
      - "DB_CONNECTION=pgsql"
      - "DB_HOST=152.1.1.1"
      - "DB_PORT=5432"
      - "DB_DATABASE=branch"
      - "DB_USERNAME=branch"
      - "DB_PASSOWRD=branch"

How do i use compose env variables inside laravel/lumen .env file? For example:


DB_CONNECTION=env('DB_CONNECTION')

But that won't work.

Please sign in or create an account to participate in this conversation.