# Docker Compose Monorepo Usage

**URL:** <https://community.doppler.com/t/docker-compose-monorepo-usage/667>\
**Category:** Need Help\
**Created:** [June 23, 2022, 6:45pm UTC](https://community.doppler.com/t/docker-compose-monorepo-usage/667 "2022-06-23T18:45:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![uncvrd](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/uncvrd/32/464_2.png) [@uncvrd](https://community.doppler.com/u/uncvrd)\
**Post date:** [June 23, 2022, 6:45pm UTC](https://community.doppler.com/t/docker-compose-monorepo-usage/667/1 "2022-06-23T18:45:02Z")

</div>

Hi! I was hoping for some help on best practices on Monorepo’s for local development.

I saw this message back in April mentioning there would be some work to add docs for mono’s ([Monorepo access token setup tedious - #2 by ryan-blunden](https://community.doppler.com/t/monorepo-access-token-setup-tedious/599/2)) but the only search I found was to highlight adding a `doppler.yaml` in each repo inside the monorepo.

Anyways! What is the best practice for setting `DOPPLER_TOKEN` when running docker compose in a local environment?

For example, I have a `docker-compose.yaml` in my root and then directories for my submodules like `/apps/api` and `/apps/web`.

I’ve followed the instructions to add an `environment` variable called `DOPPLER_TOKEN` to each item in my `docker-compose` like so:

```auto
api:
  build:
    context: .
    dockerfile: ./apps/api/Dockerfile
    target: development
  environment:
    - DOPPLER_TOKEN
  ports:
    - 4007:4007
  restart: always
    
web:
  build:
    context: .
    dockerfile: ./apps/web/Dockerfile
    target: development
  environment:
    - DOPPLER_TOKEN
  ports:
    - 4008:4008
  restart: always

```

For the compose docs, it states:

```auto
DOPPLER_TOKEN="$(doppler configs tokens create dev --plain --max-age 1m)" \
docker-compose -f docker-compose.yml up

```

However, if run from the root of my monorepo, the `DOPPLER_TOKEN` command cannot find the project to generate a token.

What is the best practice for defining multiple tokens and setting them within the compose? Should I modify the above sequence to define a `DOPPLER_TOKEN_API` and `DOPPLER_TOKEN_WEB` so that it creates two different unique tokens for each project and then I can set those env variables correctly in my docker compose?

Thanks for any insight!

---

<div class="post-metadata">

**Author:** ![watsonian](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/watsonian/32/267_2.png) [@watsonian](https://community.doppler.com/u/watsonian)\
**Post date:** [June 23, 2022, 9:22pm UTC](https://community.doppler.com/t/docker-compose-monorepo-usage/667/2 "2022-06-23T21:22:00Z")

</div>

Hi @uncvrd!

Welcome to the Doppler Community!

Having more information and established patterns for using Doppler with Monorepos is something we want to get out, but we’ve been really busy on our end and haven’t managed to get to it yet. Really sorry about that! We do also have some ideas floating around internally on how to improve our support for monorepo setups in general (e.g., modifying `doppler.yaml` to allow you to specify configuration for subdirectories, so you can just run `doppler setup` once at the top level) that we hope to implement in the future (no timeline for this yet though unfortunately!).

> [@uncvrd](#):
>
> What is the best practice for defining multiple tokens and setting them within the compose? Should I modify the above sequence to define a `DOPPLER_TOKEN_API` and `DOPPLER_TOKEN_WEB` so that it creates two different unique tokens for each project and then I can set those env variables correctly in my docker compose?

Yes, you’re on the right path there! Then you could execute doing something like this:

```auto
DOPPLER_TOKEN_API="$(doppler configs tokens create --project api --config dev dev --plain --max-age 1m)" \
DOPPLER_TOKEN_WEB="$(doppler configs tokens create --project web --config dev dev --plain --max-age 1m)" \
docker-compose -f docker-compose.yml up

```

Being as that’s a pretty long execution line – it might be worthwhile to wrap that in a small bash script you store with your project that starts up docker-compose for you with all the appropriate bits mentioned above.

Let me know if you run into more challenges and I’ll see what I can do to help!

Regards,  
-Joel

---

<div class="post-metadata">

**Author:** ![uncvrd](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/uncvrd/32/464_2.png) [@uncvrd](https://community.doppler.com/u/uncvrd)\
**Post date:** [June 23, 2022, 9:41pm UTC](https://community.doppler.com/t/docker-compose-monorepo-usage/667/3 "2022-06-23T21:41:22Z")

</div>

Thanks @watsonian for the prompt response!

I was about to report back with this similar solution, so I think this will suffice for now. I just had to make sure to reference those unique variables in the `environment` section of the docker compose instead of just passing `DOPPLER_TOKEN`

Something like:

```auto
    environment:
      - DOPPLER_TOKEN=${DOPPLER_TOKEN_API}

```

I like the idea of using the doppler yaml to reference sub directories! No worries though, the initial set up just takes a little longer without it (when you happen to have a lot of microservices 😅 )

Thanks for confirming I was on the right path!

---

<div class="post-metadata">

**Author:** ![watsonian](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/watsonian/32/267_2.png) [@watsonian](https://community.doppler.com/u/watsonian)\
**Post date:** [June 23, 2022, 9:43pm UTC](https://community.doppler.com/t/docker-compose-monorepo-usage/667/4 "2022-06-23T21:43:10Z")

</div>

No problem! Glad that’s working for you. If you have any other ideas on how we could make the monorepo experience better, feel free to open up threads on the forum here and I can get those passed on to our Product team.
