Browse Source

Dockerfile, build with Drone.

master
Syfaro 4 months ago
parent
commit
20ad776dea
5 changed files with 158 additions and 46 deletions
  1. 38
    0
      .drone.yml
  2. 9
    0
      Dockerfile
  3. 2
    1
      Pipfile
  4. 102
    41
      Pipfile.lock
  5. 7
    4
      persephone/persephone.py

+ 38
- 0
.drone.yml View File

@@ -0,0 +1,38 @@
1
+---
2
+kind: pipeline
3
+name: default
4
+
5
+platform:
6
+  os: linux
7
+  arch: amd64
8
+
9
+steps:
10
+- name: publish-image
11
+  image: plugins/docker
12
+  settings:
13
+    auto_tag: true
14
+    password:
15
+      from_secret: docker_password
16
+    registry: registry.huefox.com
17
+    repo: registry.huefox.com/persephone
18
+    username:
19
+      from_secret: docker_username
20
+  when:
21
+    branch:
22
+      - master
23
+
24
+---
25
+kind: secret
26
+name: docker_username
27
+get:
28
+  path: drone/docker
29
+  name: username
30
+
31
+---
32
+kind: secret
33
+name: docker_password
34
+get:
35
+  path: drone/docker
36
+  name: password
37
+
38
+...

+ 9
- 0
Dockerfile View File

@@ -0,0 +1,9 @@
1
+FROM python:3.7-alpine
2
+ENV FIRMWARE_FOLDER=/data/firmware DATABASE_PATH=/data/app.db
3
+WORKDIR /app
4
+VOLUME /data
5
+EXPOSE 5000
6
+COPY Pipfile Pipfile.lock /app/
7
+COPY persephone /app
8
+RUN pip3 install pipenv && pipenv install --system --deploy --ignore-pipfile
9
+ENTRYPOINT [ "waitress-serve", "--port=80", "persephone:app" ]

+ 2
- 1
Pipfile View File

@@ -6,10 +6,11 @@ name = "pypi"
6 6
 [packages]
7 7
 flask = "*"
8 8
 flask-sqlalchemy = "*"
9
+waitress = "*"
9 10
 
10 11
 [dev-packages]
11 12
 pylint = "*"
12
-"autopep8" = "*"
13
+autopep8 = "*"
13 14
 rope = "*"
14 15
 
15 16
 [requires]

+ 102
- 41
Pipfile.lock View File

@@ -1,7 +1,7 @@
1 1
 {
2 2
     "_meta": {
3 3
         "hash": {
4
-            "sha256": "c32998edda9877a37ee73bf9fd482c5d6908bbf3e274edc90f5a9ce454d33cff"
4
+            "sha256": "ff99cb41f1cf386f4ea181b7b14632df707db34bc838cfd28b8ad4c7e38f8bc5"
5 5
         },
6 6
         "pipfile-spec": 6,
7 7
         "requires": {
@@ -18,10 +18,10 @@
18 18
     "default": {
19 19
         "click": {
20 20
             "hashes": [
21
-                "sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
22
-                "sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
21
+                "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
22
+                "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
23 23
             ],
24
-            "version": "==6.7"
24
+            "version": "==7.0"
25 25
         },
26 26
         "flask": {
27 27
             "hashes": [
@@ -41,9 +41,10 @@
41 41
         },
42 42
         "itsdangerous": {
43 43
             "hashes": [
44
-                "sha256:cbb3fcf8d3e33df861709ecaf89d9e6629cff0a217bc2848f1b41cd30d360519"
44
+                "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19",
45
+                "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"
45 46
             ],
46
-            "version": "==0.24"
47
+            "version": "==1.1.0"
47 48
         },
48 49
         "jinja2": {
49 50
             "hashes": [
@@ -54,54 +55,88 @@
54 55
         },
55 56
         "markupsafe": {
56 57
             "hashes": [
57
-                "sha256:a6be69091dac236ea9c6bc7d012beab42010fa914c459791d627dad4910eb665"
58
-            ],
59
-            "version": "==1.0"
58
+                "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
59
+                "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
60
+                "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
61
+                "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
62
+                "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
63
+                "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
64
+                "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
65
+                "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
66
+                "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
67
+                "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
68
+                "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
69
+                "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
70
+                "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
71
+                "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
72
+                "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
73
+                "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
74
+                "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
75
+                "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
76
+                "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
77
+                "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
78
+                "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
79
+                "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
80
+                "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
81
+                "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
82
+                "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
83
+                "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
84
+                "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
85
+                "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"
86
+            ],
87
+            "version": "==1.1.1"
60 88
         },
61 89
         "sqlalchemy": {
62 90
             "hashes": [
63
-                "sha256:ef6569ad403520ee13e180e1bfd6ed71a0254192a934ec1dbd3dbf48f4aa9524"
91
+                "sha256:781fb7b9d194ed3fc596b8f0dd4623ff160e3e825dd8c15472376a438c19598b"
92
+            ],
93
+            "version": "==1.3.1"
94
+        },
95
+        "waitress": {
96
+            "hashes": [
97
+                "sha256:c369e238bd81ef7d61f04825f06f107c42094de60d13d8de8e71952c7c683dfe",
98
+                "sha256:de0dbd36dec695d90ac8e7464998f28c7e968a2dde3c37b06bb0a714df4dad62"
64 99
             ],
65
-            "version": "==1.2.11"
100
+            "index": "pypi",
101
+            "version": "==1.2.1"
66 102
         },
67 103
         "werkzeug": {
68 104
             "hashes": [
69
-                "sha256:c3fd7a7d41976d9f44db327260e263132466836cef6f91512889ed60ad26557c",
70
-                "sha256:d5da73735293558eb1651ee2fddc4d0dedcfa06538b8813a2e20011583c9e49b"
105
+                "sha256:96da23fa8ccecbc3ae832a83df5c722c11547d021637faacb0bec4dd2f4666c8",
106
+                "sha256:ca5c2dcd367d6c0df87185b9082929d255358f5391923269335782b213d52655"
71 107
             ],
72
-            "version": "==0.14.1"
108
+            "version": "==0.15.1"
73 109
         }
74 110
     },
75 111
     "develop": {
76 112
         "astroid": {
77 113
             "hashes": [
78
-                "sha256:292fa429e69d60e4161e7612cb7cc8fa3609e2e309f80c224d93a76d5e7b58be",
79
-                "sha256:c7013d119ec95eb626f7a2011f0b63d0c9a095df9ad06d8507b37084eada1a8d"
114
+                "sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4",
115
+                "sha256:b65db1bbaac9f9f4d190199bb8680af6f6f84fd3769a5ea883df8a91fe68b4c4"
80 116
             ],
81
-            "version": "==2.0.4"
117
+            "version": "==2.2.5"
82 118
         },
83 119
         "autopep8": {
84 120
             "hashes": [
85
-                "sha256:2284d4ae2052fedb9f466c09728e30d2e231cfded5ffd7b1a20c34123fdc4ba4"
121
+                "sha256:33d2b5325b7e1afb4240814fe982eea3a92ebea712869bfd08b3c0393404248c"
86 122
             ],
87 123
             "index": "pypi",
88
-            "version": "==1.3.5"
124
+            "version": "==1.4.3"
89 125
         },
90 126
         "colorama": {
91 127
             "hashes": [
92
-                "sha256:463f8483208e921368c9f306094eb6f725c6ca42b0f97e313cb5d5512459feda",
93
-                "sha256:48eb22f4f8461b1df5734a074b57042430fb06e1d61bd1e11b078c0fe6d7a1f1"
128
+                "sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d",
129
+                "sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48"
94 130
             ],
95 131
             "markers": "sys_platform == 'win32'",
96
-            "version": "==0.3.9"
132
+            "version": "==0.4.1"
97 133
         },
98 134
         "isort": {
99 135
             "hashes": [
100
-                "sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af",
101
-                "sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8",
102
-                "sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497"
136
+                "sha256:08f8e3f0f0b7249e9fad7e5c41e2113aba44969798a26452ee790c06f155d4ec",
137
+                "sha256:4e9e9c4bd1acd66cf6c36973f29b031ec752cbfd991c69695e4e259f9a756927"
103 138
             ],
104
-            "version": "==4.3.4"
139
+            "version": "==4.3.16"
105 140
         },
106 141
         "lazy-object-proxy": {
107 142
             "hashes": [
@@ -146,39 +181,65 @@
146 181
         },
147 182
         "pycodestyle": {
148 183
             "hashes": [
149
-                "sha256:74abc4e221d393ea5ce1f129ea6903209940c1ecd29e002e8c6933c2b21026e0",
150
-                "sha256:cbc619d09254895b0d12c2c691e237b2e91e9b2ecf5e84c26b35400f93dcfb83",
151
-                "sha256:cbfca99bd594a10f674d0cd97a3d802a1fdef635d4361e1a2658de47ed261e3a"
184
+                "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56",
185
+                "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c"
152 186
             ],
153
-            "version": "==2.4.0"
187
+            "version": "==2.5.0"
154 188
         },
155 189
         "pylint": {
156 190
             "hashes": [
157
-                "sha256:1d6d3622c94b4887115fe5204982eee66fdd8a951cf98635ee5caee6ec98c3ec",
158
-                "sha256:31142f764d2a7cd41df5196f9933b12b7ee55e73ef12204b648ad7e556c119fb"
191
+                "sha256:5d77031694a5fb97ea95e828c8d10fc770a1df6eb3906067aaed42201a8a6a09",
192
+                "sha256:723e3db49555abaf9bf79dc474c6b9e2935ad82230b10c1138a71ea41ac0fff1"
159 193
             ],
160 194
             "index": "pypi",
161
-            "version": "==2.1.1"
195
+            "version": "==2.3.1"
162 196
         },
163 197
         "rope": {
164 198
             "hashes": [
165
-                "sha256:a108c445e1cd897fe19272ab7877d172e7faf3d4148c80e7d20faba42ea8f7b2"
199
+                "sha256:6b728fdc3e98a83446c27a91fc5d56808a004f8beab7a31ab1d7224cecc7d969",
200
+                "sha256:c5c5a6a87f7b1a2095fb311135e2a3d1f194f5ecb96900fdd0a9100881f48aaf",
201
+                "sha256:f0dcf719b63200d492b85535ebe5ea9b29e0d0b8aebeb87fe03fc1a65924fdaf"
166 202
             ],
167 203
             "index": "pypi",
168
-            "version": "==0.11.0"
204
+            "version": "==0.14.0"
169 205
         },
170 206
         "six": {
171 207
             "hashes": [
172
-                "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",
173
-                "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
174
-            ],
175
-            "version": "==1.11.0"
208
+                "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
209
+                "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
210
+            ],
211
+            "version": "==1.12.0"
212
+        },
213
+        "typed-ast": {
214
+            "hashes": [
215
+                "sha256:035a54ede6ce1380599b2ce57844c6554666522e376bd111eb940fbc7c3dad23",
216
+                "sha256:037c35f2741ce3a9ac0d55abfcd119133cbd821fffa4461397718287092d9d15",
217
+                "sha256:049feae7e9f180b64efacbdc36b3af64a00393a47be22fa9cb6794e68d4e73d3",
218
+                "sha256:19228f7940beafc1ba21a6e8e070e0b0bfd1457902a3a81709762b8b9039b88d",
219
+                "sha256:2ea681e91e3550a30c2265d2916f40a5f5d89b59469a20f3bad7d07adee0f7a6",
220
+                "sha256:3a6b0a78af298d82323660df5497bcea0f0a4a25a0b003afd0ce5af049bd1f60",
221
+                "sha256:5385da8f3b801014504df0852bf83524599df890387a3c2b17b7caa3d78b1773",
222
+                "sha256:606d8afa07eef77280c2bf84335e24390055b478392e1975f96286d99d0cb424",
223
+                "sha256:69245b5b23bbf7fb242c9f8f08493e9ecd7711f063259aefffaeb90595d62287",
224
+                "sha256:6f6d839ab09830d59b7fa8fb6917023d8cb5498ee1f1dbd82d37db78eb76bc99",
225
+                "sha256:730888475f5ac0e37c1de4bd05eeb799fdb742697867f524dc8a4cd74bcecc23",
226
+                "sha256:9819b5162ffc121b9e334923c685b0d0826154e41dfe70b2ede2ce29034c71d8",
227
+                "sha256:9e60ef9426efab601dd9aa120e4ff560f4461cf8442e9c0a2b92548d52800699",
228
+                "sha256:af5fbdde0690c7da68e841d7fc2632345d570768ea7406a9434446d7b33b0ee1",
229
+                "sha256:b64efdbdf3bbb1377562c179f167f3bf301251411eb5ac77dec6b7d32bcda463",
230
+                "sha256:bac5f444c118aeb456fac1b0b5d14c6a71ea2a42069b09c176f75e9bd4c186f6",
231
+                "sha256:bda9068aafb73859491e13b99b682bd299c1b5fd50644d697533775828a28ee0",
232
+                "sha256:d659517ca116e6750101a1326107d3479028c5191f0ecee3c7203c50f5b915b0",
233
+                "sha256:eddd3fb1f3e0f82e5915a899285a39ee34ce18fd25d89582bc89fc9fb16cd2c6"
234
+            ],
235
+            "markers": "implementation_name == 'cpython'",
236
+            "version": "==1.3.1"
176 237
         },
177 238
         "wrapt": {
178 239
             "hashes": [
179
-                "sha256:d4d560d479f2c21e1b5443bbd15fe7ec4b37fe7e53d335d3b9b0a7b1226fe3c6"
240
+                "sha256:4aea003270831cceb8a90ff27c4031da6ead7ec1886023b80ce0dfe0adf61533"
180 241
             ],
181
-            "version": "==1.10.11"
242
+            "version": "==1.11.1"
182 243
         }
183 244
     }
184 245
 }

+ 7
- 4
persephone/persephone.py View File

@@ -1,6 +1,6 @@
1 1
 import hashlib
2 2
 from datetime import datetime
3
-from os import mkdir
3
+from os import mkdir, getenv
4 4
 from os.path import exists, join
5 5
 from typing import Optional
6 6
 from uuid import uuid4
@@ -12,9 +12,9 @@ from magicjson import MagicJSON
12 12
 
13 13
 app = Flask(__name__)
14 14
 
15
-app.config['FIRMWARE_FOLDER'] = 'firmware'
15
+app.config['FIRMWARE_FOLDER'] = getenv('FIRMWARE_FOLDER')
16 16
 
17
-app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
17
+app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + getenv('DATABASE_PATH')
18 18
 app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
19 19
 
20 20
 db = SQLAlchemy(app)
@@ -358,6 +358,9 @@ def api_v1_config_set(module_id):
358 358
     })
359 359
 
360 360
 
361
-if __name__ == '__main__':
361
+with app.app_context():
362 362
     db.create_all()
363
+
364
+
365
+if __name__ == '__main__':
363 366
     app.run(host='0.0.0.0', debug=True)

Loading…
Cancel
Save