forked from artefactory/xhec-mlops-project-student
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of Dockerfile and run_services.sh
- Loading branch information
1 parent
0e11670
commit fca43ea
Showing
2 changed files
with
33 additions
and
16 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,22 +1,34 @@ | ||
# Make sure to check bin/run_services.sh, which can be used here | ||
# Dockerfile | ||
|
||
# Do not forget to expose the right ports! (Check the PR_4.md) | ||
# Use Python 3.9.16 slim version | ||
FROM python:3.9.16-slim | ||
|
||
# - install the app dependencies | ||
# - Install the app dependencies | ||
RUN pip install --upgrade pip | ||
COPY requirements.in ./ | ||
RUN pip install pip-tools && pip-compile requirements_app.in | ||
|
||
# Copy the input file for pip-compile | ||
COPY requirements.in ./requirements.in | ||
|
||
# Install pip-tools and compile the requirements | ||
RUN pip install pip-tools && pip-compile requirements.in | ||
|
||
# Install the dependencies from the compiled requirements file | ||
RUN pip install --no-cache-dir -r requirements_app.txt | ||
|
||
# Copy the application file into a dossier appelé /web_service | ||
COPY ./web_service /web_service | ||
# Copy the application into the /web_service folder | ||
COPY ./src/web_service /web_service | ||
|
||
# Copy the run_services.sh file from the bin directory | ||
COPY ./bin/run_services.sh /run_services.sh | ||
|
||
# Expose the correct ports (8001 for the API, 4201 for Prefect) | ||
EXPOSE 8001 4201 | ||
|
||
# Expose les ports (8001 et 4201) | ||
EXPOSE 8000 4201 | ||
# Give execution permissions to the run_services.sh script | ||
RUN chmod +x /run_services.sh | ||
|
||
# Setting the working directory to execute command | ||
# Set the working directory to /web_service | ||
WORKDIR /web_service | ||
|
||
# Lancer l'application avec uvicorn sur le port 8000 | ||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] | ||
# Run the services via the run_services.sh script | ||
CMD ["/bin/bash", "/run_services.sh"] |
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,6 +1,11 @@ | ||
#!/bin/bash | ||
prefect config set PREFECT_API_URL=http://0.0.0.0:4200/api | ||
|
||
# TODO: Use this file in your Dockerfile to run the services | ||
sqlite3 --version | ||
|
||
prefect server start --host 0.0.0.0 --port 4201 & | ||
uvicorn src.web_service.main:app --host 0.0.0.0 --port 8001 | ||
prefect server start --host 0.0.0.0 | ||
|
||
# Go in the good directory | ||
cd src/web_service | ||
|
||
# Lancer l'API FastAPI avec Uvicorn | ||
uvicorn main:app --reload --port 8001 |