From 265ee46c4b91b175726b65d30e03c268b348f60a Mon Sep 17 00:00:00 2001 From: Magnus <97634880+MagnusS0@users.noreply.github.com> Date: Sat, 23 Sep 2023 04:55:42 +0200 Subject: [PATCH] feat: New API_KEY env variable in Dockerfile - Add API_KEY env variable in Dockerfile - Make creating Docker image more secure by using API_KEY build arg instead of hardcoding it in Dockerfile - Add .dockerignore file to ignore .git folder when building Docker image and .env file --- .dockerignore | 2 ++ Dockerfile | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..255f49d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.env +.git \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e8d961c..96f20fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,12 @@ FROM python:3.10 # Set the working directory in the container to /app WORKDIR /app +# Use ARG to accept the API key as a build argument +ARG API_KEY + +# Use ENV to set the API key as an environment variable +ENV API_KEY=$API_KEY + # Copy the poetry files COPY pyproject.toml poetry.lock /app/ @@ -14,9 +20,6 @@ RUN pip install poetry RUN poetry lock RUN poetry install -# Copy the .env file -COPY .env .env - # Copy the rest of the project COPY . .