-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
85d1859
commit aaa0c98
Showing
2 changed files
with
45 additions
and
19 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,23 +1,49 @@ | ||
# Use official Python image as the base image | ||
FROM python:3.9 | ||
# Use debian:11-slim as the base image for building | ||
FROM debian:11-slim AS build | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
# Install necessary build dependencies and set up Python virtual environment | ||
RUN apt-get update && \ | ||
apt-get install --no-install-suggests --no-install-recommends --yes \ | ||
python3-venv \ | ||
gcc \ | ||
libpython3-dev \ | ||
unzip \ | ||
wget && \ | ||
python3 -m venv /venv && \ | ||
/venv/bin/pip install --upgrade pip setuptools wheel | ||
|
||
# Download the project source code from GitHub | ||
ADD https://github.com/franklin050187/cosmo/archive/refs/heads/docker.zip /app | ||
WORKDIR /app | ||
RUN wget https://github.com/franklin050187/cosmo/archive/refs/heads/docker.zip | ||
|
||
# Unzip the downloaded file | ||
RUN unzip docker.zip && rm docker.zip && mv cosmo-docker cosmo | ||
|
||
# Change the working directory to the project directory | ||
WORKDIR /app/cosmo | ||
|
||
# Install Python dependencies | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
# Install Python dependencies from the provided requirements.txt | ||
RUN /venv/bin/pip install --disable-pip-version-check -r requirements.txt | ||
|
||
# Manually clean up the virtual environment | ||
RUN find /venv -type d -name "__pycache__" -exec rm -r {} + && \ | ||
find /venv -type f -name "*.pyc" -exec rm -r {} + && \ | ||
rm -rf /root/.cache/pip | ||
|
||
# Use the build stage as the source for the virtual environment | ||
FROM gcr.io/distroless/python3-debian11 | ||
|
||
# Copy the virtual environment from the build stage | ||
COPY --from=build /venv /venv | ||
|
||
# Copy the application code from the build stage | ||
COPY --from=build /app/cosmo /app | ||
|
||
# Set the working directory | ||
WORKDIR /venv | ||
|
||
# Expose port 8000 | ||
# Expose port | ||
EXPOSE 8000 | ||
|
||
# Command to start the server | ||
CMD ["python", "server.py"] | ||
# Set the entrypoint to run the app | ||
ENTRYPOINT ["/venv/bin/python3", "/app/server.py"] |
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