I'm trying to pass a couple of environment variables from an .env file in the root of the project to the Dockerfile's CMD. I've read through the numerous other similar questions here on SO but nothing has made this work. What am I doing wrong?
.env (in root of project)
TOKEN=AToken
DECK=ADeck
docker-compose.yml (in root of project)
version: "3"
services:
discord-initiative-savageworlds:
build:
context: .
environment:
- TOKEN=${TOKEN}
- DECK=${DECK}
And the Dockerfile (in root of project):
FROM ubuntu:latest
ARG TOKEN
ARG DECK
...Run Installers and Stuff...
COPY . .
RUN dotnet publish
RUN cd DiscordInitiative/bin/Debug/net5.0/publish
RUN echo "${TOKEN}"
CMD ./DiscordInitiative --token="${TOKEN}" --deck="${DECK}"
Running docker-compose up builds the project successfully, but the CMD shows that the environment variables are not being replaced:
Step 12/13 : RUN echo "${TOKEN}"
---> Running in 7096ef978516
Removing intermediate container 7096ef978516
---> 6985b62bb75e
Step 13/13 : CMD ./DiscordInitiative --token="${TOKEN}" --deck="${DECK}"
The project & branch this is in is on GitHub here.
Thanks for any tips!