From bebd738e3dcca80a819e7b8fffac9eb4f689b6ca Mon Sep 17 00:00:00 2001 From: Alexander Kyimpopkin <39439486+alxkp@users.noreply.github.com> Date: Sun, 12 Nov 2023 11:56:00 -0500 Subject: [PATCH] flyio initial migration configuration --- backend/.dockerignore | 3 +++ backend/Dockerfile | 3 --- backend/docker/nginx-default.conf | 2 +- backend/docker/platform-run | 20 ++++++++++++++++++++ backend/fly.toml | 25 +++++++++++++++++++++++++ frontend/fly.toml | 20 ++++++++++++++++++++ 6 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 backend/.dockerignore create mode 100644 backend/fly.toml create mode 100644 frontend/fly.toml diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 00000000..b7c39d7c --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,3 @@ +fly.toml +.git/ +*.sqlite3 diff --git a/backend/Dockerfile b/backend/Dockerfile index b814c97c..8c5e16c8 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -9,9 +9,6 @@ WORKDIR /app/ # Install dependencies RUN apt-get update \ - -# Clean up -RUN apt-get clean \ && apt-get install --no-install-recommends -y python3.11-dev pipenv python3-distutils libpq-dev gcc \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/backend/docker/nginx-default.conf b/backend/docker/nginx-default.conf index db85f3ca..6bf396eb 100644 --- a/backend/docker/nginx-default.conf +++ b/backend/docker/nginx-default.conf @@ -4,7 +4,7 @@ upstream django { server { listen 443; - server_name platform.pennlabs.org; + server_name platform-backend.fly.dev; # FastCGI authorizer for Auth Request module location = /shibauthorizer { diff --git a/backend/docker/platform-run b/backend/docker/platform-run index 8cb6012b..df92617a 100755 --- a/backend/docker/platform-run +++ b/backend/docker/platform-run @@ -1,5 +1,25 @@ #!/bin/bash +# Check if the SHIBBOLETH_CERT environment variable is set +if [ -z "${SHIBBOLETH_CERT}" ]; then + echo "The required SHIBBOLETH_CERT environment variable is not set. Exiting." + exit 1 +fi + +# Check if the SHIBBOLETH_KEY environment variable is set +if [ -z "${SHIBBOLETH_KEY}" ]; then + echo "The required SHIBBOLETH_KEY environment variable is not set. Exiting." + exit 1 +fi + +# Write the SHIBBOLETH_CERT value to the sp-cert.pem file +echo "${SHIBBOLETH_CERT}" > /etc/shibboleth/sp-cert.pem +chmod 644 /etc/shibboleth/sp-cert.pem + +# Write the SHIBBOLETH_KEY value to the sp-key.pem file +echo "${SHIBBOLETH_KEY}" > /etc/shibboleth/sp-key.pem +chmod 600 /etc/shibboleth/sp-key.pem + # Django Migrate /usr/bin/python3 /app/manage.py migrate --noinput diff --git a/backend/fly.toml b/backend/fly.toml new file mode 100644 index 00000000..49dd29a2 --- /dev/null +++ b/backend/fly.toml @@ -0,0 +1,25 @@ +# fly.toml app configuration file generated for platform-backend on 2023-10-24T11:35:39-04:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "platform-backend" +primary_region = "ewr" + +[build] + # image = "pennlabs/platform-backend:latest" + dockerfile = "Dockerfile" + +[env] + PORT = "8080" + +[http_service] + internal_port = 443 + force_https = true + auto_stop_machines = false + auto_start_machines = true + min_machines_running = 1 + +[[statics]] + guest_path = "/code/static" + url_prefix = "/static/" diff --git a/frontend/fly.toml b/frontend/fly.toml new file mode 100644 index 00000000..c5b62a42 --- /dev/null +++ b/frontend/fly.toml @@ -0,0 +1,20 @@ +# fly.toml app configuration file generated for platform-frontend on 2023-10-31T09:32:36-04:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "platform-frontend" +primary_region = "ewr" + +[build] + image = "pennlabs/platform-frontend:latest" + +[env] + DOMAIN = "platform-backend.fly.dev" + +[http_service] + internal_port = 3000 + force_https = true + auto_stop_machines = false + auto_start_machines = true + min_machines_running = 1