diff --git a/DEPLOY.md b/DEPLOY.md index fe09922..3b00643 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -1,4 +1,6 @@ Steps for deploy: 1. Try applying terraform -2. gcloud auth application-default set-quota-project `the project id` -3. retry +2. log in to firestore and add a user, generate a service account, and copy settings into .env + +Deploy app: +1. gcloud builds submit --tag gcr.io/rothbard-staging2-12345/rothbard-app diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a85471c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use Python 3.9 as base image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the requirements file first (for better caching) +COPY requirements.txt . + +# Install dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code +COPY . . + +# Expose the port the app runs on +EXPOSE 8080 + +# Command to run the application with gunicorn +CMD exec gunicorn --bind :8080 --workers 1 --threads 8 --timeout 0 app:app \ No newline at end of file diff --git a/app.py b/app.py index 7150206..fe9f7f1 100644 --- a/app.py +++ b/app.py @@ -266,5 +266,6 @@ def dashboard(): return render_template("dashboard.html", rows=detailed_rows, case_email=case_email) -if __name__ == "__main__": - app.run(debug=True, host="0.0.0.0", port=5004) +# GAE compatibility +if __name__ == "__main__" + app.run(debug=True, host="0.0.0.0", port=8080) diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..38a0cb8 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,11 @@ +steps: +- name: 'gcr.io/cloud-builders/docker' + args: ['build', '-t', 'gcr.io/$PROJECT_ID/rothbard-app', '.'] +- name: 'gcr.io/cloud-builders/docker' + args: ['push', 'gcr.io/$PROJECT_ID/rothbard-app'] +- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' + args: ['run', 'deploy', 'rothbard-app', '--image', 'gcr.io/$PROJECT_ID/rothbard-app', '--platform', 'managed', '--region', 'us-central1'] + +eventTrigger: + resource: //pubsub.googleapis.com/projects/$PROJECT_ID/topics/cloud-builds + eventType: google.pubsub.v1.PubsubMessage diff --git a/requirements.txt b/requirements.txt index 2d71f20..fd09c07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ Flask==3.0.3 firebase-admin==6.6.0 python-dotenv==1.0.1 requests==2.32.3 -itsdangerous==2.2.0 \ No newline at end of file +itsdangerous==2.2.0 +gunicorn==23.0.0 diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..8fdd907 --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.9