diff --git a/.drone.yml b/.drone.yml index 078552a..8712c0b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,187 +1,360 @@ kind: pipeline -name: auth +name: backend-auth clone: - depth: 5 - recursive: true - submodule_override: - backend-auth: https://git.makerforce.io/beep/backend-auth.git + depth: 1 steps: -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-auth - context: backend-auth/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-auth + context: backend-auth + dockerfile: backend-auth/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password --- kind: pipeline -name: bite +name: backend-bite clone: - depth: 5 + depth: 1 steps: -- name: submodules - image: docker:git - commands: - - git submodule update --init --recursive --remote -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-bite - context: backend-bite/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-bite + context: backend-bite + dockerfile: backend-bite/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password --- kind: pipeline -name: core +name: backend-core clone: - depth: 5 + depth: 1 steps: -- name: submodules - image: docker:git - commands: - - git submodule update --init --recursive --remote -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-core - context: backend-core/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-core + context: backend-core + dockerfile: backend-core/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password --- kind: pipeline -name: heartbeat +name: backend-heartbeat clone: - depth: 5 + depth: 1 steps: -- name: submodules - image: docker:git - commands: - - git submodule update --init --recursive --remote -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-heartbeat - context: backend-heartbeat/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-heartbeat + context: backend-heartbeat + dockerfile: backend-heartbeat/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password --- kind: pipeline -name: login +name: backend-login clone: - depth: 5 + depth: 1 steps: -- name: submodules - image: docker:git - commands: - - git submodule update --init --recursive --remote -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-login - context: backend-login/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-login + context: backend-login + dockerfile: backend-login/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password --- kind: pipeline -name: publish +name: backend-publish clone: - depth: 5 + depth: 1 steps: -- name: submodules - image: docker:git - commands: - - git submodule update --init --recursive --remote -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-publish - context: backend-publish/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-publish + context: backend-publish + dockerfile: backend-publish/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password --- kind: pipeline -name: signal +name: backend-signal clone: - depth: 5 + depth: 1 steps: -- name: submodules - image: docker:git - commands: - - git submodule update --init --recursive --remote -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-signal - context: backend-signal/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-signal + context: backend-signal + dockerfile: backend-signal/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password --- kind: pipeline -name: store +name: backend-store clone: - depth: 5 + depth: 1 steps: -- name: submodules - image: docker:git - commands: - - git submodule update --init --recursive --remote -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-store - context: backend-store/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-store + context: backend-store + dockerfile: backend-store/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password --- kind: pipeline -name: subscribe +name: backend-subscribe clone: - depth: 5 + depth: 1 steps: -- name: submodules - image: docker:git - commands: - - git submodule update --init --recursive --remote -- name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-subscribe - context: backend-subscribe/ - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-subscribe + context: backend-subscribe + dockerfile: backend-subscribe/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password +--- +kind: pipeline +name: backend-transcription +clone: + depth: 1 +steps: + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' + backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' + backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-transcription + context: backend-transcription + dockerfile: backend-transcription/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password +--- +kind: pipeline +name: deploy +clone: + depth: 1 +steps: + - name: nop + image: 'alpine:3.8' + commands: + - echo nop +depends_on: + - backend-auth + - backend-bite + - backend-core + - backend-heartbeat + - backend-login + - backend-publish + - backend-signal + - backend-store + - backend-subscribe + - backend-transcription diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/drone_gen.js b/drone_gen.js new file mode 100644 index 0000000..feda30b --- /dev/null +++ b/drone_gen.js @@ -0,0 +1,75 @@ +const fs = require('fs'); +const path = require('path'); +const cwd = process.cwd(); +const yaml = require('js-yaml'); + +const folders = fs.readdirSync(cwd, { withFileTypes: true }); +const submodules = folders.filter(f => + f.isDirectory() && fs.readdirSync(path.join(cwd, f.name)).includes('.git') +).map(f => f.name); +const dockers = folders.filter(f => + f.isDirectory() && fs.readdirSync(path.join(cwd, f.name)).includes('Dockerfile') +).map(f => f.name); + +const submodule_override = submodules.reduce((acc, f) => { + acc[f] = 'https://git.makerforce.io/beep/' + f + '.git'; + return acc; +}, {}); + +const yamls = dockers.map(f => ({ + kind: 'pipeline', + name: f, + clone: { + depth: 1, + }, + steps: [ + { + name: 'submodule', + image: 'plugins/git', + settings: { + recursive: true, + submodule_override, + }, + }, + { + name: 'docker', + image: 'plugins/docker', + settings: { + registry: 'registry.makerforce.io', + repo: 'registry.makerforce.io/beep/' + f, + context: f, + dockerfile: f + '/Dockerfile', + auto_tag: true, + username: { + from_secret: 'docker_username', + }, + password: { + from_secret: 'docker_password', + }, + }, + }, + ], +})) + +const deploy = { + kind: 'pipeline', + name: 'deploy', + clone: { + depth: 1, + }, + steps: [ + { + name: 'nop', + image: 'alpine:3.8', + commands: [ + 'echo nop', + ], + }, + ], + depends_on: dockers, +}; + +const droneyml = [].concat(yamls).concat(deploy).map(yaml.safeDump).join('---\n'); + +fs.writeFileSync(path.join(cwd, '.drone.yml'), droneyml); +console.log('Written to .drone.yml'); diff --git a/package.json b/package.json new file mode 100644 index 0000000..b77f5da --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "backend", + "version": "0.1.7", + "author": "Beep", + "private": true, + "scripts": { + "generate": "node drone_gen.js" + }, + "dependencies": { + "js-yaml": "^3.13.0" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..876ae29 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,28 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +js-yaml@^3.13.0: + version "3.13.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.0.tgz#38ee7178ac0eea2c97ff6d96fff4b18c7d8cf98e" + integrity sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=