-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'deploy-to-aws' into sync-deploy-to-aws-with-main
- Loading branch information
Showing
3 changed files
with
87 additions
and
54 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,49 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- deploy-to-aws | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Deploy | ||
environment: deploy-to-aws | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/setup | ||
- uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/atoti-project-template-deployment | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
- uses: aws-actions/amazon-ecr-login@v1 | ||
id: login-ecr | ||
- name: Build, tag, and push Docker image to Amazon ECR | ||
id: build-tag-and-push-docker-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: atoti-project-template | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
poetry run app build-docker $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | ||
- name: Inline variables in the task definition | ||
run: sed -i -e 's/AWS_ACCOUNT_ID/${{ secrets.AWS_ACCOUNT_ID }}/g' -e 's/AWS_REGION/${{ secrets.AWS_REGION }}/g' task-definition.json | ||
- uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
id: render-task-definition | ||
with: | ||
task-definition: task-definition.json | ||
container-name: atoti-session | ||
image: ${{ steps.build-tag-and-push-docker-image.outputs.image }} | ||
- uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.render-task-definition.outputs.task-definition }} | ||
service: atoti-project-template | ||
cluster: atoti-project-template | ||
wait-for-service-stability: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,7 @@ | ||
# Atoti Project Template | ||
|
||
This template can be used to start Atoti projects where the goal is to [go into production rather than prototyping in a notebook](https://docs.atoti.io/latest/deployment/going_from_a_notebook_to_an_app.html). | ||
Switch to the [default branch](https://github.com/atoti/project-template#readme) to learn how to use this template. | ||
|
||
On top of the `atoti` package, it comes with: | ||
## Deploy to AWS | ||
|
||
- Dependency management with [Poetry](https://python-poetry.org) | ||
- Settings management with [Pydantic](https://docs.pydantic.dev/2.5/concepts/pydantic_settings) | ||
- Testing with [pytest](https://docs.pytest.org) | ||
- Type checking with [mypy](http://mypy-lang.org) | ||
- Formatting and linting with [Ruff](https://beta.ruff.rs) | ||
- Continuous testing with [GitHub Actions](https://github.com/features/actions) | ||
|
||
## Usage | ||
|
||
### Installation | ||
|
||
- [Install `poetry`](https://python-poetry.org/docs/#installation) | ||
- Install the dependencies: | ||
|
||
```bash | ||
poetry install | ||
``` | ||
|
||
### Commands | ||
|
||
To get a list of the commands that can be executed to interact with the project, run: | ||
|
||
```bash | ||
poetry run app --help | ||
``` | ||
|
||
A few examples: | ||
|
||
- Start the app: | ||
|
||
```bash | ||
poetry run app start | ||
``` | ||
|
||
- Launch the tests: | ||
|
||
```bash | ||
poetry run app test | ||
``` | ||
|
||
- Reformat the code: | ||
|
||
```bash | ||
poetry run app format | ||
``` | ||
|
||
## Variants | ||
|
||
This repository has the following long-lived branches showcasing different aspects: | ||
|
||
- [`deploy-to-aws`](https://github.com/atoti/project-template/tree/deploy-to-aws) for deploying on AWS ECS. | ||
- [`deploy-to-heroku`](https://github.com/atoti/project-template/tree/deploy-to-heroku) for a one-click deploy to Heroku. | ||
This branch shows [the modifications](https://github.com/atoti/project-template/compare/deploy-to-aws) required to deploy a project to Amazon ECS. |
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,35 @@ | ||
{ | ||
"executionRoleArn": "atoti-project-template-role", | ||
"containerDefinitions": [ | ||
{ | ||
"name": "atoti-session", | ||
"essential": true, | ||
"logConfiguration": { | ||
"logDriver": "awslogs", | ||
"options": { | ||
"awslogs-group": "/ecs/atoti-project-template", | ||
"awslogs-region": "AWS_REGION", | ||
"awslogs-stream-prefix": "ecs" | ||
} | ||
}, | ||
"portMappings": [ | ||
{ | ||
"hostPort": 80, | ||
"protocol": "tcp", | ||
"containerPort": 80 | ||
} | ||
], | ||
"secrets": [ | ||
{ | ||
"name": "DATABASE_URL", | ||
"valueFrom": "arn:aws:secretsmanager:AWS_REGION:AWS_ACCOUNT_ID:secret:atoti-project-template/database-dsn-ZS3pzB" | ||
} | ||
] | ||
} | ||
], | ||
"family": "atoti-project-template", | ||
"cpu": "1024", | ||
"memory": "2048", | ||
"requiresCompatibilities": ["FARGATE"], | ||
"networkMode": "awsvpc" | ||
} |