-
Notifications
You must be signed in to change notification settings - Fork 2
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 #23 from GSA-TTS/dev-deployment
Setup Dev Deployment Infrastructure
- Loading branch information
Showing
23 changed files
with
916 additions
and
87 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
exclude = venv,.git,__pycache__,docs/source/conf.py,old,build,dist | ||
ignore = F403, F401 |
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,33 @@ | ||
name: Deploy Dev | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy-dev: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11.7 | ||
|
||
- name: Install poetry | ||
shell: bash | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
echo "/root/.local/bin" >> $GITHUB_PATH | ||
- name: Deploy to dev environment | ||
uses: 18f/cg-deploy-action@main | ||
with: | ||
cf_username: ${{ secrets.CF_USERNAME }} | ||
cf_password: ${{ secrets.CF_PASSWORD }} | ||
cf_org: ${{ secrets.CF_ORG }} | ||
cf_space: ${{ secrets.CF_SPACE }} | ||
app_directory: ./app | ||
push_arguments: "push -f manifest-dev.yml" |
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 |
---|---|---|
|
@@ -163,4 +163,7 @@ cython_debug/ | |
*.sqlite3 | ||
|
||
# Development storage | ||
storage/ | ||
storage/ | ||
|
||
# Development task queue | ||
celery_broker/ |
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 @@ | ||
3.11.7 |
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
documentation/adr/0004-hande-gis-data-processing-via-task-queue.md
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,28 @@ | ||
# 4. Handle GIS Data Processing via Task Queue | ||
|
||
Date: 2024-01-23 | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
## Context | ||
|
||
In order to complete relatively compute-heavy and time-consuming GIS data analysis | ||
tasks, without affecting the user's expereince, we will need to use a task queue | ||
to manage these sorts of tasks. | ||
|
||
## Decision | ||
|
||
We will use Celery as the task queue for this project. Celery is open source, | ||
relatively straightforward to configure, and actively maintained. It also | ||
allows tasks to be executed concurrently across multiple workers, which is | ||
good for scaling. | ||
|
||
## Consequences | ||
|
||
- **Architecture**: Use of Celery will be limited to the `infrastructure` | ||
directory. | ||
- **Choice of Broker**: In order to leverage our remote development environment's | ||
services, we will use Redis as a broker, keeping in mind the [caveats](https://docs.celeryq.dev/en/stable/getting-started/backends-and-brokers/redis.html#caveats) | ||
highlighted in Celery's documentation. |
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 @@ | ||
--- | ||
applications: | ||
- name: nad-ch-dev | ||
buildpacks: | ||
- https://github.com/cloudfoundry/python-buildpack | ||
services: | ||
- nad-ch-dev-postgres | ||
- nad-ch-dev-redis | ||
- nad-ch-dev-s3 | ||
random-route: true | ||
memory: 256M | ||
stack: cflinuxfs4 | ||
command: poetry run start web | ||
env: | ||
APP_ENV: dev_remote |
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,7 @@ | ||
from .base import APP_ENV | ||
|
||
|
||
if APP_ENV == 'dev_local' or APP_ENV == 'test': | ||
from .development_local import * | ||
elif APP_ENV == 'dev_remote': | ||
from .development_remote import * |
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,10 +1,9 @@ | ||
from dotenv import load_dotenv | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
|
||
load_dotenv() | ||
|
||
|
||
APP_ENV = os.getenv("APP_ENV") | ||
DATABASE_URL = os.getenv("DATABASE_URL") | ||
STORAGE_PATH = os.getenv("STORAGE_PATH") | ||
WEB_PORT = os.getenv("WEB_PORT", 3000) |
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,9 @@ | ||
import os | ||
from .base import * | ||
|
||
|
||
# Local development config | ||
STORAGE_PATH = os.getenv("STORAGE_PATH") | ||
DATABASE_URL = os.getenv("DATABASE_URL") | ||
QUEUE_BROKER_URL = os.getenv("QUEUE_BROKER_URL") | ||
QUEUE_BACKEND_URL = os.getenv("QUEUE_BACKEND_URL") |
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 @@ | ||
import json | ||
import os | ||
from .base import * | ||
|
||
|
||
def get_credentials(service_name, default={}): | ||
service = vcap_services.get(service_name, [default]) | ||
return service[0].get("credentials", default) if service else default | ||
|
||
|
||
# Remote development config | ||
vcap_services = json.loads(os.getenv("VCAP_SERVICES", "{}")) | ||
|
||
|
||
postgres_credentials = get_credentials("aws-rds") | ||
redis_credentials = get_credentials("aws-elasticache-redis") | ||
s3_credentials = get_credentials("s3") | ||
|
||
|
||
DATABASE_URL = postgres_credentials.get("uri", os.getenv("DATABASE_URL")) | ||
QUEUE_HOST = redis_credentials.get("hostname", os.getenv("QUEUE_HOST")) | ||
QUEUE_PORT = redis_credentials.get("port", os.getenv("QUEUE_PORT")) | ||
QUEUE_PASSWORD = redis_credentials.get("password", os.getenv("QUEUE_PASSWORD")) | ||
S3_BUCKET_NAME = s3_credentials.get("bucket", os.getenv("S3_BUCKET_NAME")) | ||
S3_ENDPOINT = s3_credentials.get("endpoint", os.getenv("S3_ENDPOINT")) | ||
S3_ACCESS_KEY = s3_credentials.get("access_key_id", os.getenv("S3_ACCESS_KEY")) | ||
S3_SECRET_ACCESS_KEY = s3_credentials.get( | ||
"secret_access_key", os.getenv("S3_SECRET_ACCESS_KEY") | ||
) | ||
S3_REGION = s3_credentials.get("region", os.getenv("S3_REGION")) |
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
Oops, something went wrong.