-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
9 changed files
with
96 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.env | ||
venv/ | ||
Dockerfile | ||
k8s/ | ||
.github/ | ||
CODEOWNERS |
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,7 @@ | ||
DB_HOST=localhost | ||
DB_PORT=3306 | ||
DB_PASS=your_db_password | ||
DB_USER=root | ||
DB_NAME=akatsuki | ||
DISCORD_AC_WEBHOOK=https://discordapp.com/api/webhooks/your_webhook | ||
SERVICE_READINESS_TIMEOUT=60 |
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,3 +1,4 @@ | ||
config.py | ||
__pycache__/ | ||
venv/ | ||
.env |
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,9 +1,13 @@ | ||
FROM python:3.9 | ||
|
||
WORKDIR /srv/root | ||
|
||
COPY . . | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
|
||
CMD ["python", "main.py"] | ||
COPY scripts /scripts | ||
|
||
COPY . /srv/root | ||
WORKDIR /srv/root | ||
|
||
ENTRYPOINT ["/scripts/bootstrap.sh"] |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
await_service() | ||
{ | ||
local start_ts=$(date +%s) | ||
while [ $(date +%s) -lt $((start_ts + $3)) ]; | ||
do | ||
(echo -n > /dev/tcp/$1/$2) > /dev/null | ||
if [[ $? -eq 0 ]]; then | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
local end_ts=$(date +%s) | ||
|
||
if [ $(date +%s) -ge $((start_ts + $3)) ]; then | ||
echo "Timeout occurred while waiting for $1:$2 to become available" | ||
exit 1 | ||
fi | ||
|
||
echo "$1:$2 is available after $((end_ts - start_ts)) seconds" | ||
} | ||
|
||
if [[ $# -ne 3 ]]; then | ||
echo "Usage: $0 <host> <port> <timeout>" | ||
exit 1 | ||
fi | ||
|
||
await_service $1 $2 $3 |
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,21 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
cd /srv/root | ||
|
||
if [ -z "$APP_ENV" ]; then | ||
echo "Please set APP_ENV" | ||
exit 1 | ||
fi | ||
|
||
if [[ $PULL_SECRETS_FROM_VAULT -eq 1 ]]; then | ||
pip install -i $PYPI_INDEX_URL akatsuki-cli | ||
# TODO: revert to $APP_ENV | ||
akatsuki vault get bancho-service production-k8s -o .env | ||
source .env | ||
fi | ||
|
||
# await database availability | ||
/scripts/await-service.sh $DB_HOST $DB_PORT $SERVICE_READINESS_TIMEOUT | ||
|
||
exec python3 main.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import os | ||
|
||
DB_NAME = os.environ["DB_NAME"] | ||
DB_HOST = os.environ["DB_HOST"] | ||
DB_PORT = int(os.environ["DB_PORT"]) | ||
DB_PASS = os.environ["DB_PASS"] | ||
DB_USER = os.environ["DB_USER"] | ||
DISCORD_AC_WEBHOOK = os.environ["DISCORD_AC_WEBHOOK"] |