Przeglądaj źródła

:sparkles: new tables and deployment things

tags/0.0.1
J 4 lat temu
rodzic
commit
996581f005

+ 140
- 0
.drone.yml Wyświetl plik

@@ -0,0 +1,140 @@
1
+---
2
+################
3
+#    SECRETS   #
4
+################
5
+
6
+# push_deploy_key: id_rsa from DRONE host machine
7
+
8
+
9
+################
10
+# Build & Test #
11
+################
12
+
13
+kind: pipeline
14
+name: frontend_run_tests
15
+
16
+steps:
17
+# Test the vue frontend
18
+- name: test-frontend
19
+  image: node
20
+  commands:
21
+  - pwd
22
+  - cd ./frontend
23
+  - npm install
24
+  - npm test
25
+  volumes:
26
+  # Link node_modules cache from host filesystem into container at the expected location
27
+  - name: frontend_node_cache
28
+    path: /drone/src/frontend/node_modules
29
+
30
+- name: build-frontend
31
+  image: node
32
+  commands:
33
+  - cd ./frontend
34
+  - rm -Rf ./build/*
35
+  - npx browserslist@latest --update-db
36
+  - npm run build
37
+  - ls ./build
38
+  environment:
39
+    NODE_OPTIONS: --openssl-legacy-provider
40
+  volumes:
41
+    # Link node_modules cache from host filesystem into container at the expected location
42
+    - name: frontend_node_cache
43
+      path: /drone/src/frontend/node_modules
44
+    - name: frontend_build
45
+      path: /drone/src/frontend/build
46
+
47
+volumes:
48
+  - name: frontend_node_cache
49
+    host:
50
+      path: /tmp/cache/drone/frontend/node_modules
51
+  - name: frontend_build
52
+    host:
53
+      path: /tmp/cache/drone/frontend/build
54
+---
55
+
56
+kind: pipeline
57
+name: backend_run_tests
58
+
59
+steps:
60
+# Test the vue frontend
61
+- name: test-backend
62
+  image: node
63
+  commands:
64
+  - pwd
65
+  - cd ./backend
66
+  - npm install
67
+  - npm test
68
+  volumes:
69
+  # Link node_modules cache from host filesystem into container at the expected location
70
+  - name: backend_node_cache
71
+    path: /drone/src/backend/node_modules
72
+
73
+- name: build-backend
74
+  image: node
75
+  commands:
76
+  - cd ./backend
77
+  - rm -Rf ./build/*
78
+  - npx browserslist@latest --update-db
79
+  - npm run build
80
+  - ls ./build
81
+  environment:
82
+    NODE_OPTIONS: --openssl-legacy-provider
83
+  volumes:
84
+    # Link node_modules cache from host filesystem into container at the expected location
85
+    - name: backend_node_cache
86
+      path: /drone/src/backend/node_modules
87
+    - name: backend_build
88
+      path: /drone/src/backend/build
89
+
90
+volumes:
91
+  - name: backend_node_cache
92
+    host:
93
+      path: /tmp/cache/drone/backend/node_modules
94
+  - name: backend_build
95
+    host:
96
+      path: /tmp/cache/drone/backend/build
97
+---
98
+
99
+
100
+########################
101
+# Deploy to Production #
102
+########################
103
+
104
+kind: pipeline
105
+name: deploy
106
+depends_on:
107
+  # Must run after the first pipeline
108
+  - frontend_run_tests
109
+  - backend_run_tests
110
+trigger:
111
+  status:
112
+    # Only runs if the first pipeline was fully successful
113
+    - success
114
+
115
+steps:
116
+# post-receive hook
117
+- name: push commit
118
+  image: appleboy/drone-git-push:0.2.0-linux-amd64
119
+  settings:
120
+    branch: master
121
+    remote: maeda@143.110.234.41:/opt/staging/siimee.git
122
+    remote_name: staging
123
+    force: true
124
+    ssh_key:
125
+      # !: id_rsa from DRONE machine
126
+      from_secret: push_deploy_key
127
+
128
+volumes:
129
+  - name: frontend_node_cache
130
+    host:
131
+      path: /tmp/cache/drone/frontend/node_modules
132
+  - name: frontend_build
133
+    host:
134
+      path: /tmp/cache/drone/frontend/build
135
+  - name: backend_node_cache
136
+    host:
137
+      path: /tmp/cache/drone/backend/node_modules
138
+  - name: backend_build
139
+    host:
140
+      path: /tmp/cache/drone/backend/build

+ 12
- 0
backend/db/migrations/20220403111017_create_tag_descriptions_table.js Wyświetl plik

@@ -0,0 +1,12 @@
1
+exports.up = function (knex) {
2
+    return knex.schema.createTable('tags', function (table) {
3
+        table.increments('tag_id').primary()
4
+        table.string('tag_category', 128).notNullable() // Don't over normalize
5
+        table.string('tag_description', 128).notNullable() // Don't over normalize
6
+        table.boolean('is_active').notNullable()
7
+    })
8
+}
9
+
10
+exports.down = function (knex) {
11
+    return knex.schema.dropTable('tags')
12
+}

+ 12
- 0
backend/db/migrations/20220403111037_create_tag_associations_table.js Wyświetl plik

@@ -0,0 +1,12 @@
1
+exports.up = function (knex) {
2
+    return knex.schema.createTable('tag_associations', function (table) {
3
+        table.increments('tag_association_id').primary()
4
+        table.integer('profile_id').notNullable()
5
+        table.integer('tag_id').notNullable()
6
+        table.boolean('is_deleted').notNullable()
7
+    })
8
+}
9
+
10
+exports.down = function (knex) {
11
+    return knex.schema.dropTable('tag_associations')
12
+}

+ 13
- 0
backend/db/migrations/20220403111101_create_user_passwords_table.js Wyświetl plik

@@ -0,0 +1,13 @@
1
+exports.up = function (knex) {
2
+    return knex.schema.createTable('user_identities', function (table) {
3
+        table.increments('user_pw_id').primary()
4
+        table.increments('user_id').notNullable()
5
+        table.string('uname', 16)
6
+        table.string('pw', 16)
7
+        table.boolean('is_deleted').notNullable()
8
+    })
9
+}
10
+
11
+exports.down = function (knex) {
12
+    return knex.schema.dropTable('user_identities')
13
+}

+ 12
- 0
backend/db/migrations/20220403112041_create_blocked_profiles_table.js Wyświetl plik

@@ -0,0 +1,12 @@
1
+exports.up = function (knex) {
2
+    return knex.schema.createTable('blocked_associations', function (table) {
3
+        table.increments('block_id').primary()
4
+        table.integer('profile_id').notNullable()
5
+        table.integer('profile_id_to_block').notNullable()
6
+        table.boolean('is_active').notNullable()
7
+    })
8
+}
9
+
10
+exports.down = function (knex) {
11
+    return knex.schema.dropTable('blocked_associations')
12
+}

+ 59
- 0
deployment/post-receive.sh Wyświetl plik

@@ -0,0 +1,59 @@
1
+#!/bin/bash
2
+
3
+steps=(
4
+    "navigate to project…"
5
+    "git checkout…"
6
+    "backend npm install…"
7
+    "building backend…"
8
+    "frontend npm install…"
9
+    "building frontend…"
10
+    "regenerate db data…"
11
+)
12
+commands=(
13
+    "cd /opt/staging/siimee.git"
14
+    "git --git-dir=/opt/staging/siimee.git --work-tree=/opt/staging/siimee.git checkout master -f"
15
+    "cd /opt/staging/siimee.git/backend && npm install"
16
+    "npm run build"
17
+    "cd /opt/staging/siimee.git/frontend && npm install"
18
+    "npm run build"
19
+    "cd /opt/staging/siimee.git/backend && npm run generate && npm run reseed"
20
+)
21
+
22
+
23
+SPAN=92
24
+COUNT=0
25
+hr() {
26
+    printf "\n"
27
+    
28
+    for i in $(seq 0 $SPAN) ; do
29
+        printf $1
30
+    done
31
+    printf "\n"
32
+}
33
+print_step() {
34
+    hr "-"
35
+    let step_count=$COUNT+1
36
+    printf "* POST-RECEIVE | Step: ${step_count} of ${#steps[@]}: ${1}"
37
+    hr "-"
38
+    printf "\n"
39
+    let COUNT++
40
+}
41
+run() {
42
+    # Header line 
43
+    printf "\n\n"
44
+    printf "** SIIMEE **"
45
+    hr "="
46
+    printf "\nStarting POST-RECEIVE…"
47
+    
48
+    # Body
49
+    for step in ${!steps[@]}; do
50
+        printf "\n"
51
+        print_step "${steps[$step]}"
52
+        printf "${commands[$step]}"
53
+    done
54
+
55
+    # Footer line 
56
+    printf "\n"
57
+    hr "="
58
+}
59
+run

Ładowanie…
Anuluj
Zapisz