-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from opportunity-hack/develop
Merging in config settings for automatic prod deployment on fly.io
- Loading branch information
Showing
12 changed files
with
304 additions
and
28 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,88 @@ | ||
# flyctl launch added from .gitignore | ||
**/.env* | ||
**/package-lock.json | ||
**/.flaskenv | ||
**/.DS_Store | ||
**/node_modules | ||
**/__pycache__ | ||
**/output-* | ||
**/test.log | ||
**/.firebaserc | ||
**/emulator/2022-11-20T* | ||
**/.idea/* | ||
**/.vscode/* | ||
**/venv | ||
**/scripts/Nonprofit Tracking - Nonprofits.csv | ||
**/scripts/nonprofits_round_3_from_pdf.csv | ||
**/scripts/slagenciesfy1819.pdf | ||
**/scripts/generated_image.png | ||
**/test/data/*.xlsx | ||
|
||
# flyctl launch added from emulator/.gitignore | ||
# Logs | ||
emulator/**/logs | ||
emulator/**/*.log | ||
emulator/**/npm-debug.log* | ||
emulator/**/yarn-debug.log* | ||
emulator/**/yarn-error.log* | ||
emulator/**/firebase-debug.log* | ||
emulator/**/firebase-debug.*.log* | ||
|
||
# Firebase cache | ||
emulator/**/.firebase | ||
|
||
# Firebase config | ||
|
||
# Uncomment this if you'd like others to create their own Firebase project. | ||
# For a team working on the same Firebase project(s), it is recommended to leave | ||
# it commented so all members can deploy to the same project(s) in .firebaserc. | ||
# .firebaserc | ||
|
||
# Runtime data | ||
emulator/**/pids | ||
emulator/**/*.pid | ||
emulator/**/*.seed | ||
emulator/**/*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
emulator/**/lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
emulator/**/coverage | ||
|
||
# nyc test coverage | ||
emulator/**/.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
emulator/**/.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
emulator/**/bower_components | ||
|
||
# node-waf configuration | ||
emulator/**/.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
emulator/**/build/Release | ||
|
||
# Dependency directories | ||
emulator/**/node_modules | ||
|
||
# Optional npm cache directory | ||
emulator/**/.npm | ||
|
||
# Optional eslint cache | ||
emulator/**/.eslintcache | ||
|
||
# Optional REPL history | ||
emulator/**/.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
emulator/**/*.tgz | ||
|
||
# Yarn Integrity file | ||
emulator/**/.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
emulator/**/.env | ||
fly.toml |
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,23 @@ | ||
ENVIRONMENT=test | ||
CLIENT_ORIGIN_URL=* | ||
|
||
|
||
PROPEL_AUTH_KEY=AKEY | ||
|
||
|
||
PROPEL_AUTH_URL=https://123456.propelauthtest.com | ||
|
||
|
||
OPENAI_API_KEY=DISABLED | ||
PORT=6060 | ||
FIREBASE_CERT_CONFIG={ "Something": "Something" } | ||
FLASK_APP=api | ||
FLASK_RUN_PORT=6060 | ||
FLASK_ENV=development | ||
|
||
ENC_DEC_KEY="DISABLED" | ||
|
||
|
||
SLACK_BOT_TOKEN=AKEYTODO | ||
SLACK_WEBHOOK=WEBHOOKTHINGTODO | ||
|
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,111 @@ | ||
name: 🚀 Deploy | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
- main | ||
pull_request: {} | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
name: ⬣ PYLint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: 🐍 Setup Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: 📥 Install dependencies | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
pip install -r requirements.txt | ||
- name: 🔬 Lint | ||
run: | | ||
source venv/bin/activate | ||
pylint -E api/*.py | ||
tests: | ||
name: 🧪 Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: 🐍 Setup Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: 📥 Install dependencies | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
pip install -r requirements.txt | ||
- name: 🏄 Copy test env vars | ||
run: cp .env.example .env | ||
|
||
#- name: 🧪 Run tests | ||
# run: | | ||
# source venv/bin/activate | ||
# pytest api/certificates/tests/test_always_pass.py | ||
|
||
#- name: 📊 Upload test results | ||
# uses: actions/upload-artifact@v3 | ||
# if: always() | ||
# with: | ||
# name: test-results | ||
# path: ./test-results/ | ||
# retention-days: 30 | ||
|
||
deploy: | ||
name: 🚀 Deploy | ||
runs-on: ubuntu-latest | ||
needs: [lint, tests] | ||
# only build/deploy main branch on pushes | ||
if: | ||
${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') && | ||
github.event_name == 'push' }} | ||
|
||
steps: | ||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: 👀 Read app name | ||
uses: SebRollen/[email protected] | ||
id: app_name | ||
with: | ||
file: 'fly.toml' | ||
field: 'app' | ||
|
||
- name: 🚀 Deploy Dev to https://staging.yourapp.com/ | ||
if: ${{ github.ref == 'refs/heads/develop' }} | ||
uses: superfly/[email protected] | ||
with: | ||
args: | ||
'deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} --app ${{ steps.app_name.outputs.value }}-staging' | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_STAGING_API_TOKEN }} | ||
|
||
- name: 🚀 Deploy Main to https://yourapp.com/ | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: superfly/[email protected] | ||
with: | ||
args: | ||
'deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} --app ${{ steps.app_name.outputs.value }}-prod' | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_RELEASE_API_TOKEN }} |
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,4 +1,4 @@ | ||
.env* | ||
.env | ||
package-lock.json | ||
.flaskenv | ||
.DS_Store | ||
|
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,15 @@ | ||
[MASTER] | ||
init-hook='import sys; sys.path.append("./api")' | ||
ignore=venv | ||
extension-pkg-whitelist=flask | ||
|
||
[MESSAGES CONTROL] | ||
# Disable some of the Pylint messages | ||
disable= | ||
C0114, # missing-module-docstring | ||
C0116, # missing-function-docstring | ||
R0903, # too-few-public-methods | ||
|
||
[REPORTS] | ||
# Tweak the report output | ||
reports=no |
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,18 +1,27 @@ | ||
FROM python:3.9.2-slim-buster@sha256:721de1d0aea3331da282531b8b9e428d552b89bd6fd0d0c14e634deaddc241fc as build | ||
RUN groupadd auth0 && useradd -m developer -g auth0 | ||
USER developer | ||
WORKDIR /home/developer | ||
COPY ./requirements.txt ./app/requirements.txt | ||
RUN pip install --disable-pip-version-check -r ./app/requirements.txt --target ./packages | ||
COPY ./api ./app/api | ||
COPY ./common ./app/common | ||
COPY ./gunicorn.conf.py ./app | ||
FROM python:3.10-slim | ||
|
||
FROM gcr.io/distroless/python3@sha256:eb773dd9d39f0becdab47e2ef5f1b10e2988c93a40ac8d32ca593096b409d351 | ||
COPY --from=build /home/developer/app /app | ||
COPY --from=build /home/developer/packages /packages | ||
USER 1000 | ||
EXPOSE 6060 | ||
ENV PYTHONPATH="/packages" | ||
# Set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
CMD ["/packages/gunicorn/app/wsgiapp.py","api.wsgi:app"] | ||
|
||
# Install git | ||
RUN apt-get update && apt-get install -y git | ||
|
||
# Install dependencies | ||
COPY requirements.txt /app/ | ||
RUN python -m venv venv && \ | ||
. venv/bin/activate && \ | ||
pip install --no-cache-dir -r requirements.txt | ||
|
||
EXPOSE 6060 | ||
|
||
# Bind to both IPv4 and IPv6 | ||
ENV GUNICORN_CMD_ARGS="--bind=[::]:6060 --workers=2" | ||
|
||
# Copy project | ||
COPY . /app/ | ||
# Run the application | ||
CMD ["venv/bin/gunicorn", "api.wsgi:app", "--log-file=-", "--log-level", "debug", "--preload", "--workers", "1"] |
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,15 @@ | ||
# tests/test_always_pass.py | ||
|
||
import pytest | ||
# Import env | ||
import os | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
def pytest_configure(): | ||
pytest.CERTIFICATE_TEST_REPO_URL: str = "https://github.com/whemminger/backend-ohack.dev.git" | ||
pytest.CERTIFICATE_TEST_USERNAME: str = "Squibb" | ||
pytest.CERTIFICATE_SAVE_DIR: str = "/tmp/" | ||
|
||
def test_always_pass(): | ||
assert True |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# fly.toml app configuration file generated for backend-ohack-prod on 2024-07-01T15:53:09-07:00 | ||
# | ||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
# | ||
|
||
app = 'backend-ohack' | ||
primary_region = 'sjc' | ||
|
||
[build] | ||
|
||
[http_service] | ||
internal_port = 6060 | ||
force_https = true | ||
auto_stop_machines = true | ||
auto_start_machines = true | ||
min_machines_running = 1 | ||
processes = ['app'] | ||
|
||
[[vm]] | ||
memory = '1gb' | ||
cpu_kind = 'shared' | ||
cpus = 1 |
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