Skip to content

Commit

Permalink
first version of Dockerfile and run_services.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincerf57 committed Oct 24, 2024
1 parent 0e11670 commit fca43ea
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
36 changes: 24 additions & 12 deletions Dockerfile.app
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"]
13 changes: 9 additions & 4 deletions bin/run_services.sh
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

0 comments on commit fca43ea

Please sign in to comment.