Skip to content

Commit

Permalink
feat: New API_KEY env variable in Dockerfile
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
MagnusS0 committed Sep 23, 2023
1 parent 393d1b1 commit 265ee46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
.git
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -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 . .

Expand Down

0 comments on commit 265ee46

Please sign in to comment.