-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A script has been included to check that the mysql container is active before starting the web container.
- Loading branch information
1 parent
ceb18bc
commit d094652
Showing
4 changed files
with
36 additions
and
41 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,24 +1,29 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.11-alpine | ||
|
||
# Set the working directory in the container to /app | ||
# Instala el cliente de MySQL para poder usarlo en el script de espera | ||
RUN apk add --no-cache mysql-client | ||
|
||
# Establece el directorio de trabajo en el contenedor en /app | ||
WORKDIR /app | ||
|
||
# Copy the contents of the local app/ directory to the /app directory in the container | ||
# Copia el contenido del directorio local app/ al directorio /app en el contenedor | ||
COPY app/ ./app | ||
|
||
# Copy requirements.txt at the /app working directory | ||
# Copia requirements.txt en el directorio de trabajo /app | ||
COPY requirements.txt . | ||
|
||
# Install any needed packages specified in requirements.txt | ||
# Copia el script wait-for-db.sh y establece los permisos de ejecución | ||
COPY --chmod=+x scripts/wait-for-db.sh ./scripts/ | ||
|
||
# Instala los paquetes necesarios especificados en requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Update pip | ||
# Actualiza pip | ||
RUN pip install --no-cache-dir --upgrade pip | ||
|
||
# Expose port 5000 | ||
# Expone el puerto 5000 | ||
EXPOSE 5000 | ||
|
||
# Run the application | ||
CMD flask db upgrade && flask run --host=0.0.0.0 --port=5000 --reload --debug | ||
|
||
# Ajusta el comando CMD para ejecutar correctamente el script wait-for-db.sh | ||
CMD sh ./scripts/wait-for-db.sh && flask db upgrade && flask run --host=0.0.0.0 --port=5000 --reload --debug |
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
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
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,10 @@ | ||
#!/bin/sh | ||
|
||
until mysql -h db -P 3306 -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -e 'SELECT 1' &> /dev/null | ||
do | ||
echo "MySQL is unavailable - sleeping" | ||
sleep 1 | ||
done | ||
|
||
echo "MySQL is up - executing command" | ||
exec "$@" |