Skip to content

Commit a03ba72

Browse files
authored
Migrate to ecs stack (#24)
* migrate to ecs stack
1 parent 2bf3b93 commit a03ba72

36 files changed

Lines changed: 663 additions & 574 deletions

.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Ignore files and directories commonly used by Python development
2+
**/__pycache__
3+
**/*.pyc
4+
**/*.pyo
5+
**/*.pyd
6+
**/*$py.class
7+
8+
# Ignore development and testing files
9+
**/.pytest_cache
10+
**/.coverage
11+
**/.cache
12+
**/.mypy_cache
13+
**/.vscode
14+
**/.idea
15+
**/*.egg-info
16+
**/.venv
17+
**/venv
18+
**/env
19+
**/envs
20+
**/*.log
21+
22+
# Ignore local files
23+
**/settings.py
24+
**/config.py
25+
26+
# Ignore Docker-specific files and directories
27+
Dockerfile
28+
.dockerignore
29+
docker-compose.yml
30+
31+
# Ignore other files and directories
32+
.git
33+
.gitignore
34+
*.md

.env

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
PGADMIN_DEFAULT_EMAIL=admin@redis.com
2-
PGADMIN_DEFAULT_PASSWORD=password
3-
PGADMIN_DISABLE_POSTFIX=1
4-
PGADMIN_LISTEN_ADDRESS=0.0.0.0
5-
PGADMIN_LISTEN_PORT=80
6-
DATABASE_URL=postgresql://admin:${PGADMIN_DEFAULT_PASSWORD}@db:5432
1+
DB_USER=postgres
2+
DB_PASSWORD=password
3+
DB_HOST=db
4+
DB_PORT=5432
5+
DB_NAME=dashi
6+
CIRCLE_CI_TOKEN=
7+
GH_TOKEN=
8+
SLEEP_SECONDS=2000
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy to Amazon ECS using CDK
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
env:
9+
DEFAULT_REGION: eu-west-1
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.9
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements.txt
28+
29+
- name: Configure AWS credentials
30+
uses: aws-actions/configure-aws-credentials@v1
31+
with:
32+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
33+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
34+
aws-region: ${{ env.DEFAULT_REGION }}
35+
36+
- name: Login to Amazon ECR
37+
id: login-ecr
38+
uses: aws-actions/amazon-ecr-login@v1
39+
40+
- name: Build and push Docker image
41+
uses: docker/build-push-action@v2
42+
with:
43+
context: .
44+
push: true
45+
tags: ${{ steps.login-ecr.outputs.registry }}/dashi-repository:${{ github.sha }}
46+
47+
- name: Install AWS CDK
48+
run: npm install -g aws-cdk
49+
50+
- name: Deploy using AWS CDK
51+
run: |
52+
cd cdk
53+
pip install -r requirements.txt
54+
cdk bootstrap
55+
cdk deploy --require-approval never
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CDK Diff on Pull Request
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
env:
10+
DEFAULT_REGION: eu-west-1
11+
12+
jobs:
13+
cdk_diff:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: 3.9
24+
25+
- name: Install AWS CDK
26+
run: npm install -g aws-cdk
27+
28+
- name: Configure AWS credentials
29+
uses: aws-actions/configure-aws-credentials@v1
30+
with:
31+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
32+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33+
aws-region: ${{ env.DEFAULT_REGION }}
34+
35+
- name: Run CDK Diff
36+
id: cdk_diff
37+
run: |
38+
cd cdk
39+
pip install -r requirements.txt
40+
echo "CDK_DIFF_OUTPUT<<EOF" >> $GITHUB_ENV
41+
cdk diff --context githubsha=${{ github.sha }} --require-approval never | tee >(cat - >&2) >> $GITHUB_ENV
42+
echo "EOF" >> $GITHUB_ENV
43+
44+
- name: Comment CDK Diff on Pull Request
45+
uses: actions/github-script@v5
46+
with:
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
script: |
49+
const output = `CDK Diff for commit ${{ github.sha }}:\n\`\`\`\n${process.env.CDK_DIFF_OUTPUT}\n\`\`\``;
50+
await github.rest.issues.createComment({
51+
issue_number: context.issue.number,
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
body: output,
55+
});

.github/workflows/deploy.yml

Lines changed: 0 additions & 125 deletions
This file was deleted.

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
*.swp
2+
package-lock.json
3+
.pytest_cache
4+
*.egg-info
5+
.DS_Store
6+
7+
# Editors
8+
.vscode
9+
10+
# Byte-compiled / optimized / DLL files
11+
__pycache__/
12+
*.py[cod]
13+
*$py.class
14+
15+
# Environments
16+
.env
17+
.venv
18+
env/
19+
venv/
20+
ENV/
21+
env.bak/
22+
venv.bak/
23+
24+
# CDK Context & Staging files
25+
.cdk.staging/
26+
cdk.out/
27+
/cdk.out

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:latest
2+
3+
WORKDIR /app
4+
5+
ENV PYTHONDONTWRITEBYTECODE 1
6+
ENV PYTHONUNBUFFERED 1
7+
8+
COPY requirements.txt .
9+
10+
RUN pip install -r requirements.txt
11+
12+
COPY . .

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ make setup # install prerequisites
1616
endef
1717

1818
PROJECT=dashi
19-
COMPOSE=docker-compose --env-file .env -p $(PROJECT)
19+
COMPOSE=docker-compose -p $(PROJECT)
2020

21-
SERVICES=db app gather pqadmin
21+
SERVICES=db app sidecar adminer
2222

2323
start up:
2424
@$(COMPOSE) up -d

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)