generated from kyegomez/Python-Package-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
8 changed files
with
430 additions
and
368 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 |
---|---|---|
|
@@ -18,6 +18,7 @@ eggs/ | |
.terraform | ||
.eggs/ | ||
lib/ | ||
agent_workspace/ | ||
lib64/ | ||
lambda/node_modules/ | ||
errors.txt | ||
|
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM python:3.11-slim | ||
|
||
# Set environment variables to ensure Python output is logged and bytecode is not written | ||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy the requirements file first for dependency caching | ||
COPY api/requirements.txt . | ||
|
||
# Install build dependencies, then install Python dependencies, and finally remove build tools | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends gcc build-essential && \ | ||
pip install --upgrade pip && \ | ||
pip install -r requirements.txt && \ | ||
apt-get purge -y --auto-remove gcc build-essential && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the API source code into the container | ||
COPY api/ . | ||
|
||
# Create a non-root user and change ownership of the application folder | ||
RUN adduser --disabled-password --gecos "" appuser && \ | ||
chown -R appuser /app | ||
USER appuser | ||
|
||
# Expose port 80 for the application | ||
EXPOSE 80 | ||
|
||
# Start the API using Gunicorn with Uvicorn workers | ||
CMD ["gunicorn", "api:app", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:80"] |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.