Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⏰ Entrypoint that waits for DB in Python BE #516

Merged
merged 2 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion next/public/locales/en/chat.missing.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"👉 创建一个代理,添加名称和目标,然后单击\"启动代理!\"按钮": "👉 创建一个代理,添加名称和目标,然后单击\"启动代理!\"按钮",
"👉 創建一個AI機器人,輸入名稱和目標,然後點擊\"啟動AI!\"按鈕": "👉 創建一個AI機器人,輸入名稱和目標,然後點擊\"啟動AI!\"按鈕",
"👉 Erstellen Sie einen Agenten, indem Sie einen Namen/Ziel hinzufügen und auf Bereitstellen klicken!": "👉 Erstellen Sie einen Agenten, indem Sie einen Namen/Ziel hinzufügen und auf Bereitstellen klicken!"
}
}
14 changes: 12 additions & 2 deletions platform/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM python:3.11-slim-buster as prod

RUN apt-get update && apt-get install -y \
default-libmysqlclient-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*


RUN pip install poetry==1.4.2

# Configuring poetry
Expand All @@ -21,10 +21,20 @@ RUN apt-get purge -y \
gcc \
&& rm -rf /var/lib/apt/lists/*

# Copying actuall application
# Copying actual application
COPY . /app/src/
RUN poetry install --only main



# Ensure correct line endings after these files are edited by windows
RUN chmod +x /app/src/entrypoint.sh
RUN apt-get update && apt-get install -y netcat-openbsd dos2unix \
&& dos2unix /app/src/entrypoint.sh \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["sh", "entrypoint.sh"]


CMD ["/usr/local/bin/python", "-m", "reworkd_platform"]

FROM prod as dev
Expand Down
14 changes: 14 additions & 0 deletions platform/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

host=db
port=3306

until echo "SELECT 1;" | nc "$host" "$port" > /dev/null 2>&1; do
>&2 echo "Database is unavailable - Sleeping..."
sleep 2
done

>&2 echo "Database is available! Continuing..."

# Run cmd
exec "$@"