From 209a9af804b80dd96c15234d35f5199991ce39da Mon Sep 17 00:00:00 2001 From: Phoenix Isaac Pereira Date: Wed, 5 Jun 2024 19:22:15 +0930 Subject: [PATCH] chore(ci): Update docker file to use environment variable properly --- .github/workflows/production.yml | 2 +- Dockerfile | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index aefbcb1..da9e2d6 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -2,7 +2,7 @@ name: Production on: push: - branches: [main, ci-aws] # Remove ci-aws after testing + branches: [main] env: AWS_REGION: ap-southeast-2 diff --git a/Dockerfile b/Dockerfile index d327d13..af211dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,16 +6,17 @@ WORKDIR /app # Install dependencies COPY pyproject.toml poetry.lock ./ -RUN pip install poetry \ +RUN --mount=type=secret,id=GUILD_ID,target=/run/secrets/GUILD_ID \ + --mount=type=secret,id=BOT_TOKEN,target=/run/secrets/BOT_TOKEN \ + GUILD_ID=$(cat /run/secrets/GUILD_ID) \ + BOT_TOKEN=$(cat /run/secrets/BOT_TOKEN) \ + && echo "Guild ID: $GUILD_ID" \ + && pip install poetry \ && poetry config virtualenvs.create false \ && poetry install --no-dev # Copy the rest of the application code COPY . . -# Define environment variables from secrets -RUN echo "GUILD_ID=$(cat /run/secrets/GUILD_ID)" >> /etc/environment \ - && echo "BOT_TOKEN=$(cat /run/secrets/BOT_TOKEN)" >> /etc/environment - # Run the bot CMD ["poetry", "run", "python", "src/main.py"]