Initial commit
This commit is contained in:
92
docs/deployment.md
Normal file
92
docs/deployment.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Deploy
|
||||
|
||||
## Fluxo
|
||||
|
||||
```
|
||||
1. Build Docker ──▶ 2. Push ECR ──▶ 3. Atualizar SHA no Pulumi ──▶ 4. pulumi up
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. Build da Imagem Docker
|
||||
|
||||
Execute a partir da raiz do repositório:
|
||||
|
||||
```bash
|
||||
docker build code/ --platform linux/amd64 -t <ECR_REPO_NAME>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Push para o ECR
|
||||
|
||||
### Autenticar no ECR
|
||||
|
||||
```bash
|
||||
aws ecr get-login-password --region <REGION> \
|
||||
| docker login --username AWS --password-stdin <AWS_ACCOUNT>.dkr.ecr.<REGION>.amazonaws.com
|
||||
```
|
||||
|
||||
### Tag e push
|
||||
|
||||
```bash
|
||||
docker tag <ECR_REPO_NAME>:latest \
|
||||
<AWS_ACCOUNT>.dkr.ecr.<REGION>.amazonaws.com/<ECR_REPO_NAME>:latest
|
||||
|
||||
docker push <AWS_ACCOUNT>.dkr.ecr.<REGION>.amazonaws.com/<ECR_REPO_NAME>:latest
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Obter o SHA da imagem publicada
|
||||
|
||||
Após o push, obtenha o digest da imagem no ECR:
|
||||
|
||||
```bash
|
||||
aws ecr describe-images \
|
||||
--repository-name <ECR_REPO_NAME> \
|
||||
--region <REGION> \
|
||||
--query 'sort_by(imageDetails, &imagePushedAt)[-1].imageDigest' \
|
||||
--output text
|
||||
```
|
||||
|
||||
O retorno será no formato `sha256:xxxxxxxx...`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Atualizar o SHA no Pulumi
|
||||
|
||||
Edite [infra/ecs_alb/Pulumi.Inovyo.yaml](../infra/ecs_alb/Pulumi.Inovyo.yaml) e atualize o campo `ecr_image_digest` com o valor obtido no passo anterior:
|
||||
|
||||
```yaml
|
||||
ecr_image_digest: sha256:<novo-digest>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Aplicar com Pulumi
|
||||
|
||||
```bash
|
||||
cd infra/ecs_alb
|
||||
pulumi up --stack Inovyo
|
||||
```
|
||||
|
||||
Para visualizar as mudanças antes de aplicar:
|
||||
|
||||
```bash
|
||||
pulumi preview --diff --stack Inovyo
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuração do Container
|
||||
|
||||
O `entrypoint.sh` inicia dois processos:
|
||||
|
||||
1. **FastAPI** (background): `uvicorn app.api:app --host 0.0.0.0 --port 8000`
|
||||
2. **Streamlit** (foreground): `streamlit run app/front.py --server.port 8501 --server.address 0.0.0.0 --server.headless true`
|
||||
|
||||
Após o deploy, a aplicação fica acessível pelo DNS do ALB:
|
||||
|
||||
- **API:** `http://<alb-dns>:8000`
|
||||
- **Streamlit:** `http://<alb-dns>:8501`
|
||||
Reference in New Issue
Block a user