Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ secring.*
services/

# BBDD
*.db
*.db
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ FLASK_RUN_PORT="5000"

# Database service configuration
DATABASE_URL="postgresql://db_user:db_password@localhost/db_dev"
DATABASE_TEST_URL="postgresql://db_user:db_password@localhost/db_test"
DATABASE_TEST_URL="postgresql://db_user:db_password@localhost/db_test"
2 changes: 1 addition & 1 deletion .env.api.local
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ POSTGRES_USER=db_user
PGPASSWORD=db_password

DATABASE_TEST_URL=postgresql+psycopg2://db_user:db_password@db_service:5432/db_test
DATABASE_URL=postgresql+psycopg2://db_user:db_password@db_service:5432/db_dev
DATABASE_URL=postgresql+psycopg2://db_user:db_password@db_service:5432/db_dev
2 changes: 1 addition & 1 deletion .env.db.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Database service configuration
POSTGRES_USER=db_user
POSTGRES_PASSWORD=db_password
POSTGRES_DB=db_dev
POSTGRES_DB=db_dev
2 changes: 1 addition & 1 deletion .env.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ API_PORT=5000
DATABASE_URL=sqlite:///production.db

# Deployment platform
PLATFORM_DEPLOY=AWS
PLATFORM_DEPLOY=AWS
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
ignore = F401
max-line-length = 100
max-complexity = 18
select = B,C,E,F,W,T4,B9
9 changes: 6 additions & 3 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ File: [development_pipeline.yml](development_pipeline.yml)
Event: On **Pull Request** → any branch into **develop**

Jobs:

- Build
- Unit Test
- Unit Test

### Description:

Expand All @@ -19,6 +20,7 @@ File: [staging_pipeline.yml](staging_pipeline.yml)
Event: On **Pull Request** → any branch into **staging**

Jobs:

- Build
- Unit Test
- Deploy
Expand All @@ -32,8 +34,9 @@ File: [production_pipeline.yml](production_pipeline.yml)
Event: On **Pull Request** → any branch into **main**

Jobs:

- Build
- Test
- Test
- Deploy

### Description:
### Description:
7 changes: 3 additions & 4 deletions .github/workflows/ansible/deploy-app.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---

- name: "configuration play."
- name: "configuration play."
hosts: web
user: ubuntu
become: true
gather_facts: false
vars:
vars:
- ansible_python_interpreter: /usr/bin/python3
- ansible_host_key_checking: false
- ansible_stdout_callback: yaml
Expand All @@ -18,7 +17,7 @@
pre_tasks:
- name: "wait 600 seconds for target connection to become reachable/usable."
wait_for_connection:

- name: Install aptitude
apt:
name: aptitude
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ansible/roles/deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
remote_src: yes
src: "/home/ubuntu/server/artifact-app.tar.gz"
dest: "/home/ubuntu/server"

- name: Pull mlflow image
community.docker.docker_image:
name: "{{ mlflow_image_name }}"
Expand All @@ -37,4 +37,4 @@
become: True
shell:
chdir: /home/ubuntu/server
cmd: "bash deployment/deploy.sh deploy_run_predictor data/model_config/phase-1/prob-1/model-1.yml data/model_config/phase-1/prob-2/model-1.yml 5040"
cmd: "bash deployment/deploy.sh deploy_run_predictor data/model_config/phase-1/prob-1/model-1.yml data/model_config/phase-1/prob-2/model-1.yml 5040"
16 changes: 8 additions & 8 deletions .github/workflows/development_pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: development
on:
on:
pull_request:
branches: develop

Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
Expand All @@ -47,10 +47,10 @@ jobs:
deploy-service:
needs: build-test
runs-on: ubuntu-latest
env:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
AWS_REGION: "us-east-1"
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
steps:
Expand All @@ -61,14 +61,14 @@ jobs:
id: docker_hub_auth
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build Docker Image
id: build_docker
run: |
docker compose build api_service

# Add tag
docker tag api_image:latest ${{ secrets.DOCKERHUB_USERNAME }}/api_image:latest

Expand All @@ -81,4 +81,4 @@ jobs:
with:
name: MyStackEC2
template: myStack.yaml
parameter-overrides: "MyParam1=myValue,MyParam2=${{ secrets.MY_SECRET_VALUE }}"
parameter-overrides: "MyParam1=myValue,MyParam2=${{ secrets.MY_SECRET_VALUE }}"
4 changes: 2 additions & 2 deletions .github/workflows/files/ec2-parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"ParameterKey": "VpcCIDR",
"ParameterValue": "10.0.0.0/16"
},
},
{
"ParameterKey": "PublicSubnetCIDR",
"ParameterValue": "10.0.1.0/24"
Expand All @@ -19,4 +19,4 @@
"ParameterKey": "AMItoUse",
"ParameterValue": "ami-053b0d53c279acc90"
}
]
]
42 changes: 21 additions & 21 deletions .github/workflows/files/ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ Parameters:
Type: String
Default: "ami-053b0d53c279acc90"

Resources:
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCIDR
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
Tags:
- Key: Name
Value: "Main VPC"

Expand All @@ -56,18 +56,18 @@ Resources:
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: 'us-east-1a'
AvailabilityZone: "us-east-1a"
VpcId: !Ref VPC
CidrBlock: !Ref PublicSubnetCIDR
Tags:
Tags:
- Key: Name
Value: "Public Subnet AZ1"

PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
Tags:
- Key: Name
Value: "Public Route Table"

Expand All @@ -81,9 +81,9 @@ Resources:
Type: AWS::EC2::Route
DependsOn: AttachGateway
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: '0.0.0.0/0'
GatewayId: !Ref InternetGateway
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: "0.0.0.0/0"
GatewayId: !Ref InternetGateway

SecurityGroup:
Type: AWS::EC2::SecurityGroup
Expand Down Expand Up @@ -121,24 +121,24 @@ Resources:
- Key: Name
Value: SecurityGroup

# Server EC2 Instance
ServerInstance:
# Server EC2 Instance
ServerInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref InstanceType
ImageId: !Ref AMItoUse
KeyName: !Ref KeyPairName
NetworkInterfaces:
NetworkInterfaces:
- AssociatePublicIpAddress: true
DeviceIndex: "0"
GroupSet:
- !Ref SecurityGroup
GroupSet:
- !Ref SecurityGroup
SubnetId: !Ref PublicSubnet
BlockDeviceMappings:
- DeviceName: "/dev/sdk"
Ebs:
VolumeSize: 20
# UserData:
BlockDeviceMappings:
- DeviceName: "/dev/sdk"
Ebs:
VolumeSize: 20
# UserData:
# Fn::Base64: !Sub |
# #!/bin/bash
# sudo apt-get update -y
Expand All @@ -149,10 +149,10 @@ Resources:
# echo \
# "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
# "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
# sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# sudo apt-get update -y
# apt-get install -y docker-ce
# docker run -p 80:8080 tomcat:8.0
# docker run -p 80:8080 tomcat:8.0
Tags:
- Key: Name
Value: ServerInstance
Expand All @@ -171,4 +171,4 @@ Outputs:
Name: !Join
- ""
- - !Ref AWS::StackName
- "-PublicDNS"
- "-PublicDNS"
2 changes: 1 addition & 1 deletion .github/workflows/production_pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: production
on:
on:
pull_request:
branches: main
jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/staging_pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: staging
on:
on:
pull_request:
branches: staging
jobs:
Expand All @@ -26,7 +26,7 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
Expand All @@ -38,4 +38,4 @@ jobs:
- name: Unit Tests and Integration Tests
env:
DATABASE_TEST_URL: postgresql://db_user:db_password@localhost/db_test
run: python -m flask tests
run: python -m flask tests
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
exclude: "^\
(third-party/.*)\
"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-merge-conflict # checks for some markers such as "<<<<<<<", "=======", and ">>>>>>>".
- id: detect-private-key # detects the presence of private keys.
- id: end-of-file-fixer # ensures that a file is either empty, or ends with one newline.
- id: requirements-txt-fixer # sorts entries in requirements.txt.
- id: trailing-whitespace # trims trailing whitespace at the end of lines.

# Format YAML and other files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
- id: prettier
files: \.(js|ts|jsx|tsx|css|less|html|json|markdown|md|yaml|yml)$

# Sort the order of importing libs
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile=black]

# Format Python files
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ COPY . /app
RUN chmod +x ./entrypoint.sh

# Run entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]
Loading