-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitbucket-pipelines.yml
More file actions
132 lines (130 loc) · 4.43 KB
/
bitbucket-pipelines.yml
File metadata and controls
132 lines (130 loc) · 4.43 KB
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
image: atlassian/default-image:4
pipelines:
pull-requests:
'**':
- step:
name: Test & Build
trigger: manual
script:
- echo "Running tests and build..."
branches:
main:
- step:
name: Backend Tests
image: python:3.11-slim
services:
- postgres:15
caches:
- pip
script:
- cd backend
- pip install -r requirements.txt
- python manage.py check --settings=config.settings
- python -m py_compile ../iot_agent/agent.py
- python manage.py test --settings=config.settings
- python manage.py migrate --settings=config.settings
- step:
name: Frontend Tests
image: node:18-alpine
caches:
- node
script:
- cd frontend
- npm ci
- npm run lint || true
- npm run build
artifacts:
- frontend/build/**
- step:
name: Build Backend Docker Image
services:
- docker
script:
- docker build -t atonixdev/profile-backend:$BITBUCKET_COMMIT ./backend
- docker build -t atonixdev/profile-backend:latest ./backend
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- docker push atonixdev/profile-backend:$BITBUCKET_COMMIT
- docker push atonixdev/profile-backend:latest
- step:
name: Build Frontend Docker Image
services:
- docker
script:
- docker build -t atonixdev/profile-frontend:$BITBUCKET_COMMIT ./frontend
- docker build -t atonixdev/profile-frontend:latest ./frontend
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- docker push atonixdev/profile-frontend:$BITBUCKET_COMMIT
- docker push atonixdev/profile-frontend:latest
- step:
name: Deploy to Production
deployment: production
trigger: manual
script:
- echo "Deploying to production..."
- pipe: atlassian/ssh-run:0.4.5
variables:
SSH_HOST: $PRODUCTION_HOST
SSH_USER: $PRODUCTION_USER
SSH_KEY: $SSH_PRIVATE_KEY
COMMAND: |
cd /app/profile
docker pull atonixdev/profile-backend:latest
docker pull atonixdev/profile-frontend:latest
docker-compose up -d
develop:
- step:
name: Backend Tests
image: python:3.11-slim
services:
- postgres:15
caches:
- pip
script:
- cd backend
- pip install -r requirements.txt
- python manage.py check --settings=config.settings
- python -m py_compile ../iot_agent/agent.py
- python manage.py test --settings=config.settings
- step:
name: Frontend Tests
image: node:18-alpine
caches:
- node
script:
- cd frontend
- npm ci
- npm run lint || true
- npm run build
- step:
name: Build Images
services:
- docker
script:
- docker build -t atonixdev/profile-backend:develop ./backend
- docker build -t atonixdev/profile-frontend:develop ./frontend
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- docker push atonixdev/profile-backend:develop
- docker push atonixdev/profile-frontend:develop
- step:
name: Deploy to Staging
deployment: staging
script:
- echo "Deploying to staging..."
- pipe: atlassian/ssh-run:0.4.5
variables:
SSH_HOST: $STAGING_HOST
SSH_USER: $STAGING_USER
SSH_KEY: $SSH_PRIVATE_KEY
COMMAND: |
cd /app/profile
docker pull atonixdev/profile-backend:develop
docker pull atonixdev/profile-frontend:develop
docker-compose up -d
definitions:
services:
postgres:
image: postgres:15
environment:
POSTGRES_DB: test_personal_brand_hub
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres