Skip to content

Commit 79706fd

Browse files
committed
docs(deployment): remove AWS, add Azure
1 parent b271d6f commit 79706fd

File tree

2 files changed

+23
-107
lines changed

2 files changed

+23
-107
lines changed

docs/deployment/README.md

+17-76
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,28 @@
11
# Overview
22

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.
46

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`.
79

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].
1112

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.
1615

1716
## Configuration
1817

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].
7720

7821
[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
8625
[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

docs/deployment/workflows.md

+6-31
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,19 @@ When a deployment workflow runs, the following steps are taken:
2222

2323
From the tip of the corresponding branch (e.g. `dev`)
2424

25-
### 2. Authenticate to AWS
25+
### 2. Authenticate to GHCR
2626

27-
Using secrets defined in the corresponding GitHub environment (e.g. `dev`)
27+
Using the `github.actor` and built-in `GITHUB_TOKEN` secret
2828

29-
### 3. Build and push image to ECR
29+
### 3. Build and push image to GHCR
3030

31-
Build the root [`Dockerfile`][Dockerfile], tagging with the SHA from the checked-out commit.
31+
Build the root [`Dockerfile`][Dockerfile], tagging with both the branch name (e.g. `dev`) and the SHA from the HEAD commit.
3232

33-
Push this main application image/tag into an [ECR][ecr] corresponding to the deploy environment in AWS.
34-
35-
Using the same ECR information, the (static) path to the configuration image is also output for use later in the workflow.
36-
37-
### 4. Generate ECS Task Definition
38-
39-
The [`.aws/ecs-task.json`][ecs-task-template] file serves as a template from which the corresponding ECS Task Definition is
40-
generated, with build and environment-specific information filled in.
41-
42-
Values wrapped in angle brackets, such as `<aws_account>` and `<aws_bucket>`, are replaced in the template by their
43-
corresponding secret from the GitHub environment.
44-
45-
The image names/tags generated from the ECR push step are inserted into the container definitions.
46-
47-
### 5. Deploy Task Definition to ECS
48-
49-
The final step is deploying the newly created Task Definition to the Amazon ECS cluster.
50-
51-
Once deployed, ECS does the following:
52-
53-
1. Drains existing connections
54-
2. Increments service version number
55-
3. Restarts the service
56-
57-
The GitHub Actions workflows wait for the service to restart and to reach a steady state before marking successful completion.
33+
Push this image:tag into [GHCR][ghcr].
5834

5935
[deploy-dev]: https://github.com/cal-itp/benefits/blob/dev/.github/workflows/deploy-dev.yml
6036
[deploy-test]: https://github.com/cal-itp/benefits/blob/dev/.github/workflows/deploy-test.yml
6137
[deploy-prod]: https://github.com/cal-itp/benefits/blob/dev/.github/workflows/deploy-prod.yml
6238
[dockerfile]: https://github.com/cal-itp/benefits/blob/dev/Dockerfile
63-
[ecr]: https://aws.amazon.com/ecr/
64-
[ecs-task-template]: https://github.com/cal-itp/benefits/blob/dev/.aws/ecs-task.json
39+
[ghcr]: https://github.com/features/packages
6540
[gh-actions-trigger]: https://docs.github.com/en/actions/reference/events-that-trigger-workflows

0 commit comments

Comments
 (0)