diff --git a/.circleci/config.yml b/.circleci/config.yml index 8170a69..62ea4c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -101,3 +101,11 @@ workflows: bundle-key: pmS3BucketKey deployment-group: pm-deploment-group service-role-arn: arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole + requires: + - build + filters: + branches: + only: + - development + + diff --git a/.gitignore b/.gitignore index 45f5b96..2cfd0cc 100755 --- a/.gitignore +++ b/.gitignore @@ -120,3 +120,4 @@ jwt-key.pub #redis locally redis-stable + diff --git a/Dockerfile b/Dockerfile index 99d7ac7..ddd100d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM python:3.7-alpine +FROM python:3.8.7-buster WORKDIR /usr/src ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 ENV FLASK_APP=run.py ENV FLASK_ENV=development ENV FLASK_RUN_HOST 0.0.0.0 -RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev +RUN apt-get update && apt-get install -y postgresql gcc python3-dev musl-dev build-essential libssl-dev libffi-dev RUN pip install --upgrade pip COPY requirements.txt requirements.txt RUN pip install -r requirements.txt diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 0000000..b45a1cd --- /dev/null +++ b/appspec.yml @@ -0,0 +1,9 @@ +version: 0.0 +os: linux +files: + - source: / + destination: /var/www/html/PM-API +hooks: + ApplicationStart: + - location: scripts/start_server + timeout: 300 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6506796..ad5cf8a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,13 @@ services: build: . depends_on: - db + - redis environment: + APP_ENV: development STAGE: test - SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://test:test@db/test + # SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://test:test@db/test + DATABASE_URL: postgresql://pm_admin:mypassword@db:5432/pm_db + REDIS_URL: redis://redis:6379 networks: - default ports: @@ -17,15 +21,25 @@ services: restart: always db: - environment: - POSTGRES_USER: test - POSTGRES_PASSWORD: test - POSTGRES_DB: test image: postgres:latest + environment: + - POSTGRES_USER=pm_admin + - POSTGRES_PASSWORD=mypassword + - POSTGRES_DB=pm_db networks: - default ports: - 5405:5432 restart: always volumes: - - ./postgres-data:/var/lib/postgresql/data \ No newline at end of file + - postgres_data:/var/lib/postgresql/data + + redis: + image: "redis:alpine" + networks: + - default + ports: + - "6379:6379" + +volumes: + postgres_data: \ No newline at end of file diff --git a/scripts/install_dependencies b/scripts/install_dependencies new file mode 100644 index 0000000..c42efb9 --- /dev/null +++ b/scripts/install_dependencies @@ -0,0 +1,6 @@ +#!/bin/bash +sudo apt install -y python3-pip +pip3 install virtualenv +cd /var/www/html/PM-API +source pm-api/bin/activate +pip install -r requirements.txt \ No newline at end of file diff --git a/scripts/start_server b/scripts/start_server new file mode 100644 index 0000000..297c6df --- /dev/null +++ b/scripts/start_server @@ -0,0 +1,8 @@ +#!/bin/bash +cd /var/www/html/PM-API +docker-compose up -d + + + + +