🐳 Improving env handling of docker containers

This commit is contained in:
Patrick Müller 2021-04-23 19:01:08 +02:00
parent dc84422f69
commit 2f30a8b9ce

View File

@ -1,13 +1,24 @@
FROM node:14.16.0
# Create working directory and copy required code files
RUN mkdir /workdir
ADD bot.js /workdir/bot.js
ADD package.json /workdir/package.json
ADD package-lock.json /workdir/package-lock.json
ADD .env /workdir/.env
# Set the working directory
WORKDIR /workdir
# Install npm packages
RUN npm i
# Declare required environment variables
ENV API_BEARER ""
ENV IRC_OAUTH ""
ENV ACCESS_KEY ""
# Rewrite .env file every time the container starts
CMD "echo \"API_BEARER=$API_BEARER\nIRC_OAUTH=$IRC_OAUTH\nACCESS_KEY=$ACCESS_KEY\" > /workdir/.env"
CMD "cat .env"
# Start the bot
CMD ["node", "bot.js"]