-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
# Stage 1: Build the Flask Application | ||
# ------------------- Stage 1: Build Stage ------------------------ | ||
FROM python:3.9 AS backend-builder | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
COPY backend/requirements.txt ./ | ||
# Copy the contents of the backend directory into the container at /app | ||
COPY backend/ . | ||
|
||
# Install dependencies specified in requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
COPY backend/ . | ||
# ------------------- Stage 2: Final Stage ------------------------ | ||
|
||
# Stage 2: Final Image | ||
FROM python:3.9-slim-buster | ||
# Use a slim Python 3.9 image as the final base image | ||
FROM python:3.9-slim | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Copy the built dependencies from the backend-builder stage | ||
COPY --from=backend-builder /usr/local/lib/python3.9/site-packages/ /usr/local/lib/python3.9/site-packages/ | ||
|
||
# Copy the application code from the backend-builder stage | ||
COPY --from=backend-builder /app /app | ||
|
||
# Expose port 5000 for the Flask application | ||
EXPOSE 5000 | ||
|
||
# Define the default command to run the application | ||
CMD ["python", "app.py"] | ||
|