mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
minio uploads
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
02717f4450
commit
7e36bb8711
@ -296,3 +296,13 @@ new aws.route53.Record("transactorRecord", {
|
||||
"8.9.31.18"
|
||||
]
|
||||
})
|
||||
|
||||
new aws.route53.Record("uploadRecord", {
|
||||
name: "upload.hc.engineering",
|
||||
zoneId: zoneId,
|
||||
type: "A",
|
||||
ttl: 300,
|
||||
records: [
|
||||
"8.9.31.18"
|
||||
]
|
||||
})
|
||||
|
@ -74,6 +74,7 @@ specifiers:
|
||||
'@types/express': ^4.17.13
|
||||
'@types/express-fileupload': ^1.1.7
|
||||
'@types/heft-jest': ^1.0.2
|
||||
'@types/minio': ^7.0.10
|
||||
'@types/toposort': ^2.0.3
|
||||
'@types/uuid': ^8.3.1
|
||||
'@types/ws': ^7.4.7
|
||||
@ -189,6 +190,7 @@ dependencies:
|
||||
'@types/express': 4.17.13
|
||||
'@types/express-fileupload': 1.1.7
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@types/minio': 7.0.10
|
||||
'@types/toposort': 2.0.3
|
||||
'@types/uuid': 8.3.1
|
||||
'@types/ws': 7.4.7
|
||||
@ -1484,6 +1486,12 @@ packages:
|
||||
resolution: {integrity: sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==}
|
||||
dev: false
|
||||
|
||||
/@types/minio/7.0.10:
|
||||
resolution: {integrity: sha512-PLzP2UYmS6GPZHWoiiFB7lwkFvfLR275UpqsXEAAihSb6+GWA3ZXGxq8ktYyvxgz/dYN7y2Esa+b1quI3v3S8w==}
|
||||
dependencies:
|
||||
'@types/node': 16.7.1
|
||||
dev: false
|
||||
|
||||
/@types/node/10.17.13:
|
||||
resolution: {integrity: sha512-pMCcqU2zT4TjqYFrWtYHKal7Sl30Ims6ulZ4UFXxI4xbtQqK/qqKwkDoBFCfooRqqmRu9vY3xaJRwxSh673aYg==}
|
||||
dev: false
|
||||
@ -1915,6 +1923,11 @@ packages:
|
||||
resolution: {integrity: sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==}
|
||||
dev: false
|
||||
|
||||
/@zxing/text-encoding/0.9.0:
|
||||
resolution: {integrity: sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==}
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/abab/2.0.5:
|
||||
resolution: {integrity: sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==}
|
||||
dev: false
|
||||
@ -2232,6 +2245,11 @@ packages:
|
||||
postcss-value-parser: 4.1.0
|
||||
dev: false
|
||||
|
||||
/available-typed-arrays/1.0.4:
|
||||
resolution: {integrity: sha512-SA5mXJWrId1TaQjfxUYghbqQ/hYioKmLJvPJyDuYRtXXenFNMjj4hSSt1Cf1xsuXSXrtxrVC5Ot4eU6cOtBDdA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
dev: false
|
||||
|
||||
/aws-sdk/2.969.0:
|
||||
resolution: {integrity: sha512-bDQenWDH9CdPIsgh7E6zgq2bO576teSnlQv1Oz0IwxVq+AbGsArSJXjNrvniV1l9TrqPOZk9dqBa/q4mOzwyLw==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
@ -2379,6 +2397,12 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/block-stream2/2.1.0:
|
||||
resolution: {integrity: sha512-suhjmLI57Ewpmq00qaygS8UgEq2ly2PCItenIyhMqVjo4t4pGzqMvfgJuX8iWTeSDdfSSqS6j38fL4ToNL7Pfg==}
|
||||
dependencies:
|
||||
readable-stream: 3.6.0
|
||||
dev: false
|
||||
|
||||
/body-parser/1.19.0:
|
||||
resolution: {integrity: sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==}
|
||||
engines: {node: '>= 0.8'}
|
||||
@ -3367,6 +3391,10 @@ packages:
|
||||
is-symbol: 1.0.4
|
||||
dev: false
|
||||
|
||||
/es6-error/4.1.1:
|
||||
resolution: {integrity: sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==}
|
||||
dev: false
|
||||
|
||||
/esbuild/0.12.24:
|
||||
resolution: {integrity: sha512-C0ibY+HsXzYB6L/pLWEiWjMpghKsIc58Q5yumARwBQsHl9DXPakW+5NI/Y9w4YXiz0PEP6XTGTT/OV4Nnsmb4A==}
|
||||
hasBin: true
|
||||
@ -3870,6 +3898,11 @@ packages:
|
||||
resolution: {integrity: sha512-lXatBjf3WPjmWD6DpIZxkeSsCOwqI0maYMpgDlx8g4U2qi4lbjA9oH/HD2a87G+KfsUmo5WbJFmqBZlPxtptag==}
|
||||
dev: false
|
||||
|
||||
/fast-xml-parser/3.19.0:
|
||||
resolution: {integrity: sha512-4pXwmBplsCPv8FOY1WRakF970TjNGnGnfbOnLqjlYvMiF1SR3yOHyxMR/YCXpPTOspNF5gwudqktIP4VsWkvBg==}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/fastest-levenshtein/1.0.12:
|
||||
resolution: {integrity: sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow==}
|
||||
dev: false
|
||||
@ -4005,6 +4038,10 @@ packages:
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: false
|
||||
|
||||
/foreach/2.0.5:
|
||||
resolution: {integrity: sha1-C+4AUBiusmDQo6865ljdATbsG5k=}
|
||||
dev: false
|
||||
|
||||
/forever-agent/0.6.1:
|
||||
resolution: {integrity: sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=}
|
||||
dev: false
|
||||
@ -4282,6 +4319,13 @@ packages:
|
||||
engines: {node: '>= 0.4'}
|
||||
dev: false
|
||||
|
||||
/has-tostringtag/1.0.0:
|
||||
resolution: {integrity: sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
dependencies:
|
||||
has-symbols: 1.0.2
|
||||
dev: false
|
||||
|
||||
/has-value/0.3.1:
|
||||
resolution: {integrity: sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@ -4734,6 +4778,13 @@ packages:
|
||||
engines: {node: '>=6'}
|
||||
dev: false
|
||||
|
||||
/is-generator-function/1.0.10:
|
||||
resolution: {integrity: sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
dependencies:
|
||||
has-tostringtag: 1.0.0
|
||||
dev: false
|
||||
|
||||
/is-glob/3.1.0:
|
||||
resolution: {integrity: sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@ -4826,6 +4877,17 @@ packages:
|
||||
has-symbols: 1.0.2
|
||||
dev: false
|
||||
|
||||
/is-typed-array/1.1.7:
|
||||
resolution: {integrity: sha512-VxlpTBGknhQ3o7YiVjIhdLU6+oD8dPz/79vvvH4F+S/c8608UCVa9fgDpa1kZgFoUST2DCgacc70UszKgzKuvA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
dependencies:
|
||||
available-typed-arrays: 1.0.4
|
||||
call-bind: 1.0.2
|
||||
es-abstract: 1.18.5
|
||||
foreach: 2.0.5
|
||||
has-tostringtag: 1.0.0
|
||||
dev: false
|
||||
|
||||
/is-typedarray/1.0.0:
|
||||
resolution: {integrity: sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=}
|
||||
dev: false
|
||||
@ -5456,6 +5518,10 @@ packages:
|
||||
resolution: {integrity: sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=}
|
||||
dev: false
|
||||
|
||||
/json-stream/1.0.0:
|
||||
resolution: {integrity: sha1-GjhU4o0rvuqzHMfd9oPS3cVlJwg=}
|
||||
dev: false
|
||||
|
||||
/json-stringify-safe/5.0.1:
|
||||
resolution: {integrity: sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=}
|
||||
dev: false
|
||||
@ -5849,6 +5915,25 @@ packages:
|
||||
resolution: {integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==}
|
||||
dev: false
|
||||
|
||||
/minio/7.0.19:
|
||||
resolution: {integrity: sha512-DOGKauWLdmj0/y2QKXdnrhqyzRFEnUteHi6q382uujg9TjSDrA84BiQVppS2Ew6V8Rcg+2IaRkF4GR34zw9sIA==}
|
||||
engines: {node: '>= 4'}
|
||||
dependencies:
|
||||
async: 3.2.1
|
||||
block-stream2: 2.1.0
|
||||
es6-error: 4.1.1
|
||||
fast-xml-parser: 3.19.0
|
||||
json-stream: 1.0.0
|
||||
lodash: 4.17.21
|
||||
mime-types: 2.1.32
|
||||
mkdirp: 0.5.5
|
||||
querystring: 0.2.0
|
||||
through2: 3.0.2
|
||||
web-encoding: 1.1.5
|
||||
xml: 1.0.1
|
||||
xml2js: 0.4.19
|
||||
dev: false
|
||||
|
||||
/mixin-deep/1.3.2:
|
||||
resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@ -7955,6 +8040,13 @@ packages:
|
||||
resolution: {integrity: sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==}
|
||||
dev: false
|
||||
|
||||
/through2/3.0.2:
|
||||
resolution: {integrity: sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==}
|
||||
dependencies:
|
||||
inherits: 2.0.4
|
||||
readable-stream: 3.6.0
|
||||
dev: false
|
||||
|
||||
/thunky/1.1.0:
|
||||
resolution: {integrity: sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==}
|
||||
dev: false
|
||||
@ -8317,6 +8409,17 @@ packages:
|
||||
resolution: {integrity: sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=}
|
||||
dev: false
|
||||
|
||||
/util/0.12.4:
|
||||
resolution: {integrity: sha512-bxZ9qtSlGUWSOy9Qa9Xgk11kSslpuZwaxCg4sNIDj6FLucDab2JxnHwyNTCpHMtK1MjoQiWQ6DiUMZYbSrO+Sw==}
|
||||
dependencies:
|
||||
inherits: 2.0.4
|
||||
is-arguments: 1.1.0
|
||||
is-generator-function: 1.0.10
|
||||
is-typed-array: 1.1.7
|
||||
safe-buffer: 5.2.1
|
||||
which-typed-array: 1.1.6
|
||||
dev: false
|
||||
|
||||
/utils-merge/1.0.1:
|
||||
resolution: {integrity: sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=}
|
||||
engines: {node: '>= 0.4.0'}
|
||||
@ -8416,6 +8519,14 @@ packages:
|
||||
minimalistic-assert: 1.0.1
|
||||
dev: false
|
||||
|
||||
/web-encoding/1.1.5:
|
||||
resolution: {integrity: sha512-HYLeVCdJ0+lBYV2FvNZmv3HJ2Nt0QYXqZojk3d9FJOLkwnuhzM9tmamh8d7HPM8QqjKH8DeHkFTx+CFlWpZZDA==}
|
||||
dependencies:
|
||||
util: 0.12.4
|
||||
optionalDependencies:
|
||||
'@zxing/text-encoding': 0.9.0
|
||||
dev: false
|
||||
|
||||
/webidl-conversions/4.0.2:
|
||||
resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==}
|
||||
dev: false
|
||||
@ -8656,6 +8767,18 @@ packages:
|
||||
resolution: {integrity: sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=}
|
||||
dev: false
|
||||
|
||||
/which-typed-array/1.1.6:
|
||||
resolution: {integrity: sha512-DdY984dGD5sQ7Tf+x1CkXzdg85b9uEel6nr4UkFg1LoE9OXv3uRuZhe5CoWdawhGACeFpEZXH8fFLQnDhbpm/Q==}
|
||||
engines: {node: '>= 0.4'}
|
||||
dependencies:
|
||||
available-typed-arrays: 1.0.4
|
||||
call-bind: 1.0.2
|
||||
es-abstract: 1.18.5
|
||||
foreach: 2.0.5
|
||||
has-tostringtag: 1.0.0
|
||||
is-typed-array: 1.1.7
|
||||
dev: false
|
||||
|
||||
/which/1.3.1:
|
||||
resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==}
|
||||
hasBin: true
|
||||
@ -8770,6 +8893,10 @@ packages:
|
||||
resolution: {integrity: sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==}
|
||||
dev: false
|
||||
|
||||
/xml/1.0.1:
|
||||
resolution: {integrity: sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=}
|
||||
dev: false
|
||||
|
||||
/xml2js/0.4.19:
|
||||
resolution: {integrity: sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==}
|
||||
dependencies:
|
||||
@ -9875,7 +10002,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
file:projects/upload.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-ak4xpI/m2ZKbxOIOnPnJ/+TxbaNxCKLgIeihA516iRc1r66eyRRgyIig2Ebx4JZw+VMToUvbSrZuITdLZAFPAA==, tarball: file:projects/upload.tgz}
|
||||
resolution: {integrity: sha512-rHxwiXBd/wGYiFnYh9IoX/2IIYFiLAK8aCeBtS08QB0zZRn8/f6V8QrbFDk1SoW9J5ZIimQx0jXX+ER3DnQo8w==, tarball: file:projects/upload.tgz}
|
||||
id: file:projects/upload.tgz
|
||||
name: '@rush-temp/upload'
|
||||
version: 0.0.0
|
||||
@ -9884,12 +10011,14 @@ packages:
|
||||
'@types/express': 4.17.13
|
||||
'@types/express-fileupload': 1.1.7
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@types/minio': 7.0.10
|
||||
'@types/node': 16.7.1
|
||||
'@types/uuid': 8.3.1
|
||||
'@types/ws': 7.4.7
|
||||
'@typescript-eslint/eslint-plugin': 4.28.5_a8e83fcad666e1ba86be4b2e27a20aea
|
||||
aws-sdk: 2.969.0
|
||||
cors: 2.8.5
|
||||
esbuild: 0.12.24
|
||||
eslint: 7.32.0
|
||||
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
@ -9897,6 +10026,7 @@ packages:
|
||||
express: 4.17.1
|
||||
express-fileupload: 1.2.1
|
||||
jwt-simple: 0.5.6
|
||||
minio: 7.0.19
|
||||
mongodb: 4.1.1
|
||||
server-core: 0.1.0
|
||||
ts-node: 10.2.1_f50b86b1778cd2aa4e5405c08bb39559
|
||||
@ -9998,12 +10128,13 @@ packages:
|
||||
dev: false
|
||||
|
||||
file:projects/workspace.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-8vO7UTqdUdxIPbiMIKXV54zDnFD63L75+7Z9mTnVO5Ln6Nb5rf+ZfYloA2pDauRKp0Rf7ItIYPhjmEpp8QE+Ow==, tarball: file:projects/workspace.tgz}
|
||||
resolution: {integrity: sha512-Du1dJ9lKTjiLDhFbpM6d7IL3XaPksCXlPeaKBG3xz4v2v1odoMjXqMA/fjGnw091khBJi0+QqnsjR7zt2/ROpQ==, tarball: file:projects/workspace.tgz}
|
||||
id: file:projects/workspace.tgz
|
||||
name: '@rush-temp/workspace'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@types/minio': 7.0.10
|
||||
'@types/node': 16.7.1
|
||||
'@typescript-eslint/eslint-plugin': 4.28.5_a8e83fcad666e1ba86be4b2e27a20aea
|
||||
esbuild: 0.12.24
|
||||
@ -10012,6 +10143,7 @@ packages:
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 4.3.1
|
||||
jwt-simple: 0.5.6
|
||||
minio: 7.0.19
|
||||
mongodb: 4.1.1
|
||||
ts-node: 10.2.1_typescript@4.3.5
|
||||
transitivePeerDependencies:
|
||||
|
@ -169,7 +169,8 @@ module.exports = {
|
||||
},
|
||||
'/upload': {
|
||||
// target: 'https://anticrm-upload.herokuapp.com/',
|
||||
target: 'http://localhost:3000/',
|
||||
// target: 'http://localhost:3000/',
|
||||
target: 'https://upload.hc.engineering/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/upload': '' },
|
||||
logLevel: 'debug'
|
||||
|
9
server/upload/Dockerfile
Normal file
9
server/upload/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
FROM node
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY bundle.js ./
|
||||
|
||||
EXPOSE 3000
|
||||
CMD [ "node", "bundle.js" ]
|
31
server/upload/kube/deployment.yml
Normal file
31
server/upload/kube/deployment.yml
Normal file
@ -0,0 +1,31 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: upload
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: upload
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: upload
|
||||
spec:
|
||||
containers:
|
||||
- name: app
|
||||
image: anticrm/upload
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: TRANSACTOR_URL
|
||||
value: ws://transactor/
|
||||
- name: ELASTIC_URL
|
||||
value: http://dev-elasticsearch-coordinating-only:9200/
|
||||
- name: MINIO_ENDPOINT
|
||||
value: minio
|
||||
- name: MINIO_ACCESS_KEY
|
||||
value: 22pYVftgFj
|
||||
- name: MINIO_SECRET_KEY
|
||||
value: l8FkhAXSbQBUpeYJ7APYOSXyWp4qEXR4Gccjb2zo
|
24
server/upload/kube/ingress.yml
Normal file
24
server/upload/kube/ingress.yml
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "nginx"
|
||||
cert-manager.io/issuer: "letsencrypt-prod"
|
||||
name: upload-ingress
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
- upload.hc.engineering
|
||||
secretName: upload-tls
|
||||
rules:
|
||||
- host: upload.hc.engineering
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: upload
|
||||
port:
|
||||
number: 80
|
||||
path: /
|
||||
pathType: Prefix
|
10
server/upload/kube/service.yml
Normal file
10
server/upload/kube/service.yml
Normal file
@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: upload
|
||||
spec:
|
||||
selector:
|
||||
app: upload
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 3000
|
@ -7,7 +7,10 @@
|
||||
"scripts": {
|
||||
"start": "ts-node src/__start.ts",
|
||||
"build": "heft build",
|
||||
"lint:fix": "eslint --fix src"
|
||||
"lint:fix": "eslint --fix src",
|
||||
"bundle": "esbuild src/__start.ts --bundle --minify --platform=node > bundle.js",
|
||||
"docker:build": "docker build -t anticrm/upload .",
|
||||
"docker:push": "docker push anticrm/upload"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anticrm/platform-rig":"~0.6.0",
|
||||
@ -23,7 +26,9 @@
|
||||
"ts-node":"^10.2.0",
|
||||
"@types/express-fileupload":"^1.1.7",
|
||||
"@types/uuid":"^8.3.1",
|
||||
"@types/cors":"^2.8.12"
|
||||
"@types/cors":"^2.8.12",
|
||||
"@types/minio":"^7.0.10",
|
||||
"esbuild":"^0.12.24"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/platform": "~0.6.5",
|
||||
@ -37,6 +42,7 @@
|
||||
"@anticrm/server-core":"~0.6.1",
|
||||
"@anticrm/chunter":"~0.6.0",
|
||||
"@anticrm/core":"~0.6.11",
|
||||
"@anticrm/contrib":"~0.6.0"
|
||||
"@anticrm/contrib":"~0.6.0",
|
||||
"minio":"^7.0.19"
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
//
|
||||
|
||||
import { start } from './app'
|
||||
import { Client } from 'minio'
|
||||
|
||||
const url = process.env.TRANSACTOR_URL
|
||||
if (url === undefined) {
|
||||
@ -28,4 +29,30 @@ if (elasticUrl === undefined) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
start(url, elasticUrl, 3000)
|
||||
const minioEndpoint = process.env.MINIO_ENDPOINT
|
||||
if (minioEndpoint === undefined) {
|
||||
console.error('please provide minio endpoint')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const minioAccessKey = process.env.MINIO_ACCESS_KEY
|
||||
if (minioAccessKey === undefined) {
|
||||
console.error('please provide minio access key')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const minioSecretKey = process.env.MINIO_SECRET_KEY
|
||||
if (minioSecretKey === undefined) {
|
||||
console.error('please provide minio secret key')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const minio = new Client({
|
||||
endPoint: minioEndpoint,
|
||||
port: 9000,
|
||||
useSSL: false,
|
||||
accessKey: minioAccessKey,
|
||||
secretKey: minioSecretKey
|
||||
})
|
||||
|
||||
start(url, elasticUrl, minio, 3000)
|
||||
|
@ -19,14 +19,16 @@ import fileUpload, { UploadedFile } from 'express-fileupload'
|
||||
import cors from 'cors'
|
||||
import { S3 } from 'aws-sdk'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
// import { decode } from 'jwt-simple'
|
||||
import { decode } from 'jwt-simple'
|
||||
|
||||
import type { Space, Ref, Account, Doc } from '@anticrm/core'
|
||||
import { TxFactory } from '@anticrm/core'
|
||||
// import type { Token } from '@anticrm/server-core'
|
||||
import type { Token } from '@anticrm/server-core'
|
||||
import chunter from '@anticrm/chunter'
|
||||
import { createContributingClient } from '@anticrm/contrib'
|
||||
|
||||
import { Client } from 'minio'
|
||||
|
||||
// import { createElasticAdapter } from '@anticrm/elastic'
|
||||
|
||||
const BUCKET = 'anticrm-upload-9e4e89c'
|
||||
@ -45,6 +47,15 @@ async function awsUpload (file: UploadedFile): Promise<string> {
|
||||
return id
|
||||
}
|
||||
|
||||
async function minioUpload (minio: Client, workspace: string, file: UploadedFile): Promise<string> {
|
||||
const id = uuid()
|
||||
|
||||
const resp = await minio.putObject(workspace, id, file.data)
|
||||
|
||||
console.log(resp)
|
||||
return id
|
||||
}
|
||||
|
||||
async function createAttachment (endpoint: string, token: string, account: Ref<Account>, space: Ref<Space>, attachmentTo: Ref<Doc>, collection: string, name: string, file: string): Promise<void> {
|
||||
const txFactory = new TxFactory(account)
|
||||
const tx = txFactory.createTxCreateDoc(chunter.class.Attachment, space, {
|
||||
@ -63,7 +74,7 @@ async function createAttachment (endpoint: string, token: string, account: Ref<A
|
||||
* @public
|
||||
* @param port -
|
||||
*/
|
||||
export function start (transactorEndpoint: string, elasticUrl: string, port: number): void {
|
||||
export function start (transactorEndpoint: string, elasticUrl: string, minio: Client, port: number): void {
|
||||
const app = express()
|
||||
|
||||
app.use(cors())
|
||||
@ -86,8 +97,9 @@ export function start (transactorEndpoint: string, elasticUrl: string, port: num
|
||||
|
||||
try {
|
||||
const token = authHeader.split(' ')[1]
|
||||
// const payload = decode(token ?? '', 'secret', false) as Token
|
||||
const fileId = await awsUpload(file as UploadedFile)
|
||||
const payload = decode(token ?? '', 'secret', false) as Token
|
||||
// const fileId = await awsUpload(file as UploadedFile)
|
||||
const fileId = await minioUpload(minio, payload.workspace, file as UploadedFile)
|
||||
|
||||
const space = req.query.space as Ref<Space>
|
||||
const attachmentTo = req.query.attachmentTo as Ref<Doc>
|
||||
|
@ -5,6 +5,7 @@ WORKDIR /usr/src/app
|
||||
COPY bundle.js ./
|
||||
|
||||
ENV TRANSACTOR_URL ws://transactor/
|
||||
ENV MINIO_ENDPOINT minio
|
||||
|
||||
EXPOSE 8080
|
||||
CMD [ "bash" ]
|
||||
|
@ -21,12 +21,14 @@
|
||||
"eslint-plugin-node":"11",
|
||||
"eslint":"^7.32.0",
|
||||
"ts-node":"^10.2.1",
|
||||
"esbuild":"~0.12.24"
|
||||
"esbuild":"~0.12.24",
|
||||
"@types/minio":"~7.0.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/core": "~0.6.11",
|
||||
"mongodb": "^4.1.0",
|
||||
"@anticrm/contrib": "~0.6.0",
|
||||
"jwt-simple": "~0.5.6"
|
||||
"jwt-simple": "~0.5.6",
|
||||
"minio": "~7.0.19"
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,10 @@
|
||||
#
|
||||
|
||||
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace default mng-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
|
||||
kubectl run mng-mongodb-client --rm --tty -i --restart='Never' --env="MONGO_URL=mongodb://root:$MONGODB_ROOT_PASSWORD@mng-mongodb:27017/" --image anticrm/tools --command -- bash
|
||||
export MINIO_ACCESS_KEY=$(kubectl get secret --namespace default minio -o jsonpath="{.data.access-key}" | base64 --decode)
|
||||
export MINIO_SECRET_KEY=$(kubectl get secret --namespace default minio -o jsonpath="{.data.secret-key}" | base64 --decode)
|
||||
|
||||
kubectl run mng-mongodb-client --rm --tty -i --restart='Never' \
|
||||
--env="MONGO_URL=mongodb://root:$MONGODB_ROOT_PASSWORD@mng-mongodb:27017/" \
|
||||
--env="MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY" \
|
||||
--env="MINIO_SECRET_KEY=$MINIO_SECRET_KEY" --image anticrm/tools --command -- bash
|
||||
|
@ -15,6 +15,7 @@
|
||||
//
|
||||
|
||||
import { createWorkspace } from '.'
|
||||
import { Client } from 'minio'
|
||||
|
||||
const mongoUrl = process.env.MONGO_URL
|
||||
if (mongoUrl === undefined) {
|
||||
@ -28,13 +29,39 @@ if (transactorUrl === undefined) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const minioEndpoint = process.env.MINIO_ENDPOINT
|
||||
if (minioEndpoint === undefined) {
|
||||
console.error('please provide minio endpoint')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const minioAccessKey = process.env.MINIO_ACCESS_KEY
|
||||
if (minioAccessKey === undefined) {
|
||||
console.error('please provide minio access key')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const minioSecretKey = process.env.MINIO_SECRET_KEY
|
||||
if (minioSecretKey === undefined) {
|
||||
console.error('please provide minio secret key')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const db = process.argv[2]
|
||||
if (db === undefined) {
|
||||
console.error('Please specify the database.')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const minio = new Client({
|
||||
endPoint: minioEndpoint,
|
||||
port: 9000,
|
||||
useSSL: false,
|
||||
accessKey: minioAccessKey,
|
||||
secretKey: minioSecretKey
|
||||
})
|
||||
|
||||
console.log('creating model...')
|
||||
createWorkspace(mongoUrl, db, transactorUrl).then(() => {
|
||||
createWorkspace(mongoUrl, db, transactorUrl, minio).then(() => {
|
||||
console.log(`done.`)
|
||||
}).catch(error => { console.error(error) })
|
||||
|
@ -18,6 +18,7 @@ import { MongoClient, Document } from 'mongodb'
|
||||
import core, { DOMAIN_TX, Tx } from '@anticrm/core'
|
||||
import { createContributingClient } from '@anticrm/contrib'
|
||||
import { encode } from 'jwt-simple'
|
||||
import { Client } from 'minio'
|
||||
|
||||
import * as txJson from './model.tx.json'
|
||||
|
||||
@ -26,7 +27,7 @@ const txes = (txJson as any).default as Tx[]
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function createWorkspace (mongoUrl: string, dbName: string, clientUrl: string): Promise<void> {
|
||||
export async function createWorkspace (mongoUrl: string, dbName: string, clientUrl: string, minio: Client): Promise<void> {
|
||||
const client = new MongoClient(mongoUrl)
|
||||
try {
|
||||
await client.connect()
|
||||
@ -49,6 +50,9 @@ export async function createWorkspace (mongoUrl: string, dbName: string, clientU
|
||||
await contrib.tx(tx)
|
||||
}
|
||||
contrib.close()
|
||||
|
||||
console.log('create minio bucket')
|
||||
await minio.makeBucket(dbName, 'k8s')
|
||||
} finally {
|
||||
await client.close()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user