|
1 | 1 | # Overview
|
2 | 2 |
|
3 |
| -The Django application gets built into a [Docker image](https://github.com/cal-itp/benefits/blob/dev/Dockerfile) with [NGINX](https://www.nginx.com/) and [Gunicorn](https://gunicorn.org/). SQLite is used within that same container to store configuration data and S3 is used for secrets; there is no external database. |
| 3 | +The Django application gets built into a [Docker image][dockerfile] with [NGINX](https://www.nginx.com/) and |
| 4 | +[Gunicorn](https://gunicorn.org/). SQLite is used within that same container to store configuration data and Azure Blobs are |
| 5 | +used for secrets; there is no external database. |
4 | 6 |
|
5 |
| -The application is deployed to [AWS Elastic Container Service (ECS)][ecs-welcome] using a |
6 |
| -[Task Definition][ecs-task-definition] generated from the template file at [`.aws/ecs-task.json`][ecs-task-definition-template]. |
| 7 | +The application is deployed to an [Azure Web App Container][az-webapp] using three separate environments for `dev`, `test`, |
| 8 | +and `prod`. |
7 | 9 |
|
8 |
| -The application is deployed into three separate AWS environments for `dev`, `test`, and `prod`. |
9 |
| -[GitHub Environments][gh-environments] exist corresponding to each AWS deployment environment, with secrets and protection |
10 |
| -rules specific to each GitHub Environment. |
| 10 | +A [GitHub Action][gh-actions] per environment is responsible for building that branch's image and pushing to [GitHub Container |
| 11 | +Registry (GHCR)][ghcr]. |
11 | 12 |
|
12 |
| -A [GitHub Action][gh-actions] per Environment is responsible for deploying that Environment's branch to the corresponding |
13 |
| -AWS location. |
14 |
| - |
15 |
| -The [architecture overview from August 2021][arch-overview] goes into more detail. |
| 13 | +GitHub POSTs a [webhook][gh-webhooks] to the Azure Web App when an [image is published to GHCR][gh-webhook-event], telling |
| 14 | +Azure to restart the app and pull the latest image. |
16 | 15 |
|
17 | 16 | ## Configuration
|
18 | 17 |
|
19 |
| -Configuration data (see [Configuration](../configuration/)) is stored in AWS S3 buckets for each deployment environment. |
20 |
| - |
21 |
| -### ECS runtime |
22 |
| - |
23 |
| -The ECS Task Definition includes a `containerDefinition`, using the [AWS CLI][aws-cli] Docker image, to pull the fixture data |
24 |
| -from the corresponding S3 bucket during service (re)start. This configuration is copied into a volume that is also mounted |
25 |
| -into the main application container. |
26 |
| - |
27 |
| -The main application `containerDefinition` uses [`dependsOn`][depends-on] to ensure that the AWS CLI container task has |
28 |
| -completed successfully, before starting itself. |
29 |
| - |
30 |
| -Both containers use the [`environmentFiles`][env-files] setting to load an `.env` file from their deploy environment's S3 |
31 |
| -bucket. |
32 |
| - |
33 |
| -### Local AWS |
34 |
| - |
35 |
| -!!! warning |
36 |
| - |
37 |
| - The following command will decrypt and download the `benefits` configuration from S3 into the `.aws/config` directory on |
38 |
| - your local computer. Be sure this is what you want to do. |
39 |
| - |
40 |
| -To copy the AWS configuration locally, fill in the appropriate values in your local `.env` file: |
41 |
| - |
42 |
| -- for the AWS connection: |
43 |
| - |
44 |
| - ```console |
45 |
| - AWS_DEFAULT_REGION=us-west-2 |
46 |
| - AWS_ACCESS_KEY_ID=access-key-id |
47 |
| - AWS_SECRET_ACCESS_KEY=secret-access-key |
48 |
| - AWS_BUCKET=bucket-name |
49 |
| - ``` |
50 |
| - |
51 |
| -- and to ensure Django uses the downloaded configuration: |
52 |
| - |
53 |
| - ```console |
54 |
| - DJANGO_INIT_PATH=config/<file>.json |
55 |
| - ``` |
56 |
| - |
57 |
| -and then pull the files down to your local computer: |
58 |
| - |
59 |
| -```bash |
60 |
| -docker compose run s3pull |
61 |
| -``` |
62 |
| - |
63 |
| -### Update AWS |
64 |
| - |
65 |
| -!!! warning |
66 |
| - |
67 |
| - The following command will send the **entire contents** of the `.aws/config` directory from your local computer into the |
68 |
| - `benefits` S3 bucket for the configured environment. Be sure this is what you want to do. |
69 |
| - |
70 |
| -A Docker Compose service can also be used to push updates to the configuration data into S3 for the given deploy environment: |
71 |
| - |
72 |
| -Ensure you have content (e.g. an `.env` or `config.json` file) inside `.aws/config` in your local repository and then run: |
73 |
| - |
74 |
| -```bash |
75 |
| -docker compose run s3push |
76 |
| -``` |
| 18 | +[Configuration settings](../configuration/README.md) are stored as Application Configuration variables in Azure. |
| 19 | +[Fixtures](../configuration/fixtures.md) are stored as blobs in in Azure Storage, and [mounted into the Web App container][az-mount]. |
77 | 20 |
|
78 | 21 | [arch-overview]: https://docs.google.com/document/d/1rwYcp2ps_JNn9WmjqUfYpPeuMoj1FZu5DTUloQEQ5iQ/edit#heading=h.afetf83gz28y
|
79 |
| -[aws-cli]: https://aws.amazon.com/cli/ |
80 |
| -[depends-on]: https://docs.aws.amazon.com/AmazonECS/latest/userguide/task_definition_parameters.html#container_definition_dependson |
81 |
| -[ecs-task-definition]: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html |
82 |
| -[ecs-task-definition-template]: https://github.com/cal-itp/benefits/blob/dev/.aws/ecs-task.json |
83 |
| -[ecs-welcome]: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html |
84 |
| -[env-files]: https://docs.aws.amazon.com/AmazonECS/latest/userguide/taskdef-envfiles.html |
85 |
| -[fixtures]: https://github.com/cal-itp/benefits/tree/dev/fixtures/ |
| 22 | +[dockerfile]: https://github.com/cal-itp/benefits/blob/dev/Dockerfile |
| 23 | +[az-webapp]: https://azure.microsoft.com/en-us/services/app-service/containers/ |
| 24 | +[az-mount]: https://docs.microsoft.com/en-us/azure/app-service/configure-connect-to-azure-storage?tabs=portal&pivots=container-linux |
86 | 25 | [gh-actions]: https://docs.github.com/en/actions
|
87 |
| -[gh-environments]: https://docs.github.com/en/actions/reference/environments |
| 26 | +[gh-webhook-event]: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#package |
| 27 | +[gh-webhooks]: https://docs.github.com/en/github-ae@latest/developers/webhooks-and-events/webhooks |
| 28 | +[ghcr]: https://github.com/features/packages |
0 commit comments