diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..8ef2a7f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,58 @@ +name: Deploy +on: + push: + branches: + - dev + - stg + - main + +jobs: + deploy: + runs-on: self-hosted + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Update Pip + run: | + python3 -m pip install --upgrade pip + + - name: Install Docker Compose + run: | + python3 -m pip install docker-compose --upgrade + + - name: Install AWS CLI + run: | + python3 -m pip install awscli --upgrade + + - name: Install AWS Elastic Beanstalk ClI + run: | + python3 -m pip install awsebcli --upgrade + + - name: Configure AWS Region + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-region: us-east-1 + + - name: Extract Environment + shell: bash + run: | + if [ ${GITHUB_REF} == "refs/heads/main" ]; then + echo "##[set-output name=result;]$(echo "prd")" + else + echo "##[set-output name=result;]$(echo ${GITHUB_REF#refs/heads/})" + fi + id: extract_environment + + - name: Login to AWS ECR + id: login_ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, Tag, and Push Image to AWS ECR + env: + ENV: ${{ steps.extract_environment.outputs.result }} + IMAGE_TAG: latest + run: | + export ENV=$ENV + docker-compose build + docker-compose push diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9218f95 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: "3.8" +services: + maestro: + build: . + image: 468720548566.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:latest + container_name: maestro + restart: always + ports: + - 3333:3333 + + node_exporter: + image: prom/node-exporter:v1.3.1 + container_name: node_exporter + restart: always + volumes: + - /proc:/host/proc:ro + - /sys:/host/sys:ro + - /:/rootfs:ro + - /run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro + command: + - '--path.procfs=/host/proc' + - '--path.rootfs=/rootfs' + - '--path.sysfs=/host/sys' + - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)' + - '--collector.systemd' + - '--collector.processes' + network_mode: host + pid: host