-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.yml
132 lines (120 loc) · 2.71 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
---
kind: pipeline
type: docker
name: Test API / UI
environment:
APP_VERSION: 0.0.1
steps:
- name: Test API
image: python:3.8.5
environment:
APP_ENV: test
DJANGO_SETTINGS_MODULE: "settings.settings"
DJANGO_DEBUG: True
DJANGO_ALLOWED_HOSTS: "*"
DJANGO_DB_HOST: db
DJANGO_DB_NAME: float
DJANGO_DB_USER: drone
DJANGO_DB_PASSWORD: drone_pwd
DJANGO_SECRET_KEY: "(。◕‿‿◕。)"
commands:
- apt-get update && apt-get install -y postgresql
- db/wait-for-postgres.sh
- cd api/src
- pip install -r ../pip-requirements/dev.txt
- python manage.py test apps
- name: Test UI
image: cypress/included:5.4.0
commands:
- cd ui/
- npm ci
- npm run test:e2e:ci
services:
- name: db
image: postgres:12-alpine
environment:
POSTGRES_USER: drone
POSTGRES_PASSWORD: drone_pwd
POSTGRES_DB: float
---
kind: pipeline
type: docker
name: Build Images
steps:
- name: Build API
image: plugins/docker
settings:
repo: floatcms/api
dockerfile: ./api/Dockerfile
context: ./api
auto_tag: true
build_args:
- PIP_REQ=production
username:
from_secret: docker_username
password:
from_secret: docker_token
depends_on:
- Test API / UI
trigger:
branch:
- develop
event:
- push
---
kind: pipeline
type: docker
name: Deploy to AWS
steps:
- name: Build UI
image: node:14.0
commands:
- cd ui/
- npm ci
- npm run build
- name: Deploy UI to S3
image: plugins/s3
settings:
bucket: floatql.com
region: us-west-2
access_key:
from_secret: s3_user_access_key_id
secret_key:
from_secret: s3_user_secret_access_key
source: ui/build/**/*
target: /
strip_prefix: ui/build/
depends_on:
- Build UI
- name: Deploy API to EC2
image: floatcms/ssh
environment:
PRIVATE_KEY:
from_secret: rsa_private_key
EC2_PUBLIC_IP_ADDRESS:
from_secret: ec2_public_ip_address
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_TOKEN:
from_secret: docker_token
commands:
- mkdir -p ~/.ssh
- echo "$PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 700 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -H 'cloud.drone.io' >> ~/.ssh/known_hosts
- chmod +x ./deploy.sh
- touch .env
- echo DOCKER_USERNAME=$DOCKER_USERNAME >> .env
- echo DOCKER_TOKEN=$DOCKER_TOKEN >> .env
- scp -o StrictHostKeyChecking=no -r ./conf.d ./.env ./env.properties ./api/env/production.properties ./docker-compose.prod.yml ec2-user@$EC2_PUBLIC_IP_ADDRESS:/home/ec2-user/app
- rm .env
- bash ./deploy.sh
depends_on:
- Build Images
trigger:
branch:
- develop
event:
- push