[open-event-legacy/deploy: 1/3] Backport stuff to make life easier
- From: Tom Tryfonidis <tomtryf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [open-event-legacy/deploy: 1/3] Backport stuff to make life easier
- Date: Thu, 4 Apr 2019 16:13:00 +0000 (UTC)
commit e732eb0b402ba2ef062c59749142d5e63c962727
Author: Tom Tryfonidis <tomtryf gmail com>
Date: Thu Apr 4 10:03:30 2019 +0300
Backport stuff to make life easier
That includes dockerfile, runtime scripts
Dockerfile | 8 ++++++--
kubernetes/run.sh | 19 ++++++++++++-------
manage.py | 10 +++++++++-
3 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/Dockerfile b/Dockerfile
index 7eea98cb..05834280 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y wget git ca-certificates curl && update
# install deps
-RUN apt-get install -y --no-install-recommends build-essential python-dev libpq-dev libevent-dev
libmagic-dev && apt-get clean -y && curl -sL https://deb.nodesource.com/setup_4.x | bash && apt-get install
-y --force-yes nodejs && apt-get clean -y && npm install bower -g && npm cache clean
+RUN apt-get install -y --no-install-recommends build-essential python-dev libpq-dev libevent-dev
libmagic-dev libssl-dev && apt-get clean -y && curl -sL https://deb.nodesource.com/setup_4.x | bash &&
apt-get install -y --force-yes nodejs && apt-get clean -y && npm install bower -g && npm cache clean
# nodejs bower
# ^^ https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
@@ -29,4 +29,8 @@ RUN pip install --no-cache-dir -r requirements.txt && bower install --allow-root
# copy remaining files
COPY . .
-CMD bash scripts/docker_run.sh
+RUN chown -R 1000150000:0 ./static && \
+ chmod -R 664 ./static && \
+ find ./static -type d -exec chmod 775 {} +
+
+ENTRYPOINT ["kubernetes/run.sh"]
diff --git a/kubernetes/run.sh b/kubernetes/run.sh
index 8662c27f..f188bae6 100755
--- a/kubernetes/run.sh
+++ b/kubernetes/run.sh
@@ -1,15 +1,20 @@
#!/bin/bash
-echo "Deploying ${DEPLOYMENT}"
-export REDIS_URL=redis://${REDIS_SERVICE_HOST}:${REDIS_SERVICE_PORT}/0
-export DATABASE_URL=postgresql://postgres:test@${POSTGRES_SERVICE_HOST}:${POSTGRES_SERVICE_PORT}/opev
-python manage.py initialize_db -c open_event_test_user fossasia org:fossasia
-python manage.py db upgrade > /dev/null 2>&1
-if [ "$DEPLOYMENT" == "web" ]
+echo "[LOG] Deploying ${DEPLOYMENT}"
+echo "[LOG] Using database: ${DATABASE_URL}"
+echo "[LOG] Using redis: ${REDIS_URL}"
+
+if [ "$DEPLOYMENT" = "web" ]
then
+ echo "[LOG] Preparing database"
+ python manage.py prepare_kubernetes_db
+ echo "[LOG] Running migrations"
+ python manage.py db upgrade
+ echo "[LOG] Starting gunicorn on port 8080"
gunicorn -b 0.0.0.0:8080 app:app -w 1 --enable-stdio-inheritance --log-level "warning" --proxy-protocol
fi
-if [ "$DEPLOYMENT" == "celery" ]
+if [ "$DEPLOYMENT" = "celery" ]
then
+ echo "[LOG] Starting celery worker"
export INTEGRATE_SOCKETIO=false
celery worker -A app.celery --loglevel=warning
fi
diff --git a/manage.py b/manage.py
index d8c9a21c..4bee1a27 100644
--- a/manage.py
+++ b/manage.py
@@ -90,9 +90,17 @@ def initialize_db(credentials):
print "Could not create tables. Either database does not exist or tables already created"
if populate_data:
credentials = credentials.split(":")
- DataManager.create_super_admin(credentials[0], credentials[1])
+ admin_email = os.environ.get('SUPER_ADMIN_EMAIL', credentials[0])
+ admin_password = os.environ.get('SUPER_ADMIN_PASSWORD', credentials[1])
+ DataManager.create_super_admin(admin_email, admin_password)
populate()
+ else:
+ print("[LOG] Tables already exist. Skipping data population & creation.")
+@manager.command
+def prepare_kubernetes_db(credentials='open_event_test_user fossasia org:fossasia'):
+ with app.app_context():
+ initialize_db(credentials)
if __name__ == "__main__":
manager.run()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]