Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
Split the api into backend/frontend packages so that the dependency r…
Browse files Browse the repository at this point in the history
…esolution works

Arguably, flegall/monopack#660 could be a better solution if it's fixed
  • Loading branch information
farcaller committed Nov 15, 2020
1 parent 5982238 commit 99f00f2
Show file tree
Hide file tree
Showing 14 changed files with 165 additions and 41 deletions.
26 changes: 18 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#### build the metanotes-server-api package in the debian container first, as it cannot be built within alpine

FROM node:15-slim as build_protoc

RUN set -ex; \
Expand All @@ -8,26 +10,35 @@ RUN set -ex; \
chmod 755 /usr/bin/protoc-gen-grpc-web

WORKDIR /usr/src/app
COPY .eslintrc.js package.json yarn.lock ./
COPY .eslintrc.js package.json yarn.lock tsconfig.* ./
COPY packages/metanotes-server-api/package.json ./packages/metanotes-server-api/package.json
COPY packages/metanotes-server-api-web/package.json ./packages/metanotes-server-api-web/package.json

WORKDIR /usr/src/app/packages
COPY ./packages/metanotes-server-api ./metanotes-server-api
COPY ./packages/metanotes-server-api-web ./metanotes-server-api-web
RUN yarn install

WORKDIR /usr/src/app/packages/metanotes-server-api
RUN yarn
COPY ./packages/metanotes-server-api ./
RUN yarn build

WORKDIR /usr/src/app/packages/metanotes-server-api-web
RUN yarn build

####

FROM node:15-alpine3.12 as build_deps

RUN apk --update add python2 build-base

WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN apk --update add python2 build-base; yarn
COPY . ./
RUN yarn

WORKDIR /usr/src/app/packages/metanotes-server-api
RUN yarn
COPY --from=build_protoc /usr/src/app/packages/metanotes-server-api/lib ./lib
WORKDIR /usr/src/app/packages/metanotes-server-api-web
COPY --from=build_protoc /usr/src/app/packages/metanotes-server-api-web/lib ./lib

####

Expand Down Expand Up @@ -66,8 +77,7 @@ FROM node:15-alpine3.12 as deploy_server

COPY --from=build_server /usr/src/app/packages/metanotes-server/dist/* /usr/src/app/
WORKDIR /usr/src/app
CMD ["sh", "-c", "exec node ./main.js \"${DATA_DIR}\" \"${LISTEN_ADDRESS}\""]

CMD ["sh", "-c", "exec node ./main.js \"${DATA_DIR}/db.sqlite\" \"${LISTEN_ADDRESS}\""]

####

Expand Down
4 changes: 4 additions & 0 deletions metanotes.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"name": "server-api",
"path": "./packages/metanotes-server-api"
},
{
"name": "server-api-web",
"path": "./packages/metanotes-server-api-web"
},
{
"name": "-- root --",
"path": "."
Expand Down
1 change: 1 addition & 0 deletions packages/metanotes-server-api-web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib
36 changes: 36 additions & 0 deletions packages/metanotes-server-api-web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@metanotes/server-api-web",
"version": "0.1.0",
"description": "",
"main": "lib/index.js",
"scripts": {
"build:watch": "nodemon",
"build": "mkdir -p ./lib && grpc_tools_node_protoc -Isrc api.proto --js_out=import_style=commonjs:lib/ --grpc-web_out=import_style=commonjs+dts,mode=grpcweb:lib/ && grpc_tools_node_protoc --plugin=protoc-gen-ts=../../node_modules/.bin/protoc-gen-ts --ts_out=grpc_js:lib/ -Isrc src/api.proto && tsc"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"google-protobuf": "^3.14.0-rc.1",
"grpc-web": "^1.2.1"
},
"devDependencies": {
"@types/google-protobuf": "^3.7.4",
"grpc": "^1.24.4",
"grpc-tools": "^1.9.1",
"grpc_tools_node_protoc_ts": "^5.0.1",
"typescript": "^4.0.5"
},
"nodemonConfig": {
"ignore": [
"**/*.test.ts",
"**/*.spec.ts",
".git",
"node_modules"
],
"watch": [
"src"
],
"exec": "yarn build",
"ext": "proto"
}
}
1 change: 1 addition & 0 deletions packages/metanotes-server-api-web/src/api.proto
31 changes: 31 additions & 0 deletions packages/metanotes-server-api-web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"extends": "../../tsconfig.json",

"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"declaration": true,
"strict": true,
"sourceMap": true,
"outDir": "lib",
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*"
]
},
"typeRoots": ["./node_modules/@types", "./typings"],
},
"files": [
"src/index.ts",
],
"exclude": [
"node_modules",
".vscode",
"**/*.test.ts",
"**/*.spec.ts"
]
}
7 changes: 0 additions & 7 deletions packages/metanotes-server-api/babel.config.js

This file was deleted.

17 changes: 3 additions & 14 deletions packages/metanotes-server-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,17 @@
"version": "0.1.0",
"description": "",
"main": "lib/index.js",
"exports": {
".": "./lib/index.js",
"./web": "./lib/web.js"
},
"scripts": {
"build:watch": "nodemon",
"build": "mkdir -p ./lib && grpc_tools_node_protoc -Isrc api.proto --js_out=import_style=commonjs:lib/ --grpc_out=grpc_js:lib/ --grpc-web_out=import_style=commonjs+dts,mode=grpcweb:lib/ && grpc_tools_node_protoc --plugin=protoc-gen-ts=../../node_modules/.bin/protoc-gen-ts --ts_out=grpc_js:lib/ -Isrc src/api.proto && babel -d lib/ -x .ts src/"
"build": "mkdir -p ./lib && grpc_tools_node_protoc -Isrc api.proto --js_out=import_style=commonjs:lib/ --grpc_out=grpc_js:lib/ && grpc_tools_node_protoc --plugin=protoc-gen-ts=../../node_modules/.bin/protoc-gen-ts --ts_out=grpc_js:lib/ -Isrc src/api.proto && tsc"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"google-protobuf": "^3.14.0-rc.1"
},
"peerDependencies": {
"@grpc/grpc-js": "^1.2.0",
"grpc-web": "^1.2.1"
"google-protobuf": "^3.14.0-rc.1",
"@grpc/grpc-js": "^1.2.0"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@types/google-protobuf": "^3.7.4",
"grpc": "^1.24.4",
"grpc-tools": "^1.9.1",
Expand Down
1 change: 0 additions & 1 deletion packages/metanotes-server-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
},
"files": [
"src/index.ts",
"src/web.ts"
],
"exclude": [
"node_modules",
Expand Down
4 changes: 2 additions & 2 deletions packages/metanotes-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"@metanotes/server-api": "0.1.0",
"google-protobuf": "^3.14.0",
"grpc-web": "^1.2.1",
"node-gyp": "^7.1.2",
"sql-template-strings": "^2.2.2",
"sqlite": "^4.0.17",
"sqlite3": "^5.0.0",
"node-gyp": "^7.1.2"
"sqlite3": "^5.0.0"
},
"devDependencies": {
"@types/google-protobuf": "^3.7.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/metanotes-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@babel/standalone": "^7.12.4",
"@metanotes/filter": "0.1.0",
"@metanotes/server-api": "0.1.0",
"@metanotes/server-api-web": "0.1.0",
"@octokit/auth-token": "^2.4.2",
"@octokit/rest": "^18.0.6",
"@reduxjs/toolkit": "^1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/metanotes-store/src/api/metanotes-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import * as emptyPb from 'google-protobuf/google/protobuf/empty_pb';

import { pb, grpc_web_pb } from '@metanotes/server-api/lib/web';
import { pb, grpc_web_pb } from '@metanotes/server-api-web';
import { Scribble, fromProto, toProto } from '../features/scribbles/scribble';


Expand Down
74 changes: 67 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# yarn lockfile v1


"@babel/cli@^7.11.6":
"@babel/cli@^7.11.6", "@babel/cli@^7.12.1":
version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.12.1.tgz#e08a0b1cb6fcd4b9eb6a606ba5602c5c0fe24a0c"
integrity sha512-eRJREyrfAJ2r42Iaxe8h3v6yyj1wu9OyosaUHW6UImjGf9ahGL9nsFNh7OCopvtcPL8WnEo7tp78wrZaZ6vG9g==
Expand Down Expand Up @@ -51,7 +51,7 @@
semver "^5.4.1"
source-map "^0.5.0"

"@babel/[email protected]", "@babel/core@^7.1.0", "@babel/core@^7.11.6", "@babel/core@^7.7.5", "@babel/core@^7.8.4", "@babel/core@^7.9.0":
"@babel/[email protected]", "@babel/core@^7.1.0", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.7.5", "@babel/core@^7.8.4", "@babel/core@^7.9.0":
version "7.12.3"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.3.tgz#1b436884e1e3bff6fb1328dc02b208759de92ad8"
integrity sha512-0qXcZYKZp3/6N2jKYVxZv0aNCsxTSVCiK72DTiTYZAu7sjg73W0/aynWjMbiGd87EQL4WyA8reiJVh92AVla9g==
Expand Down Expand Up @@ -1161,7 +1161,7 @@
"@babel/plugin-transform-react-jsx-source" "^7.12.1"
"@babel/plugin-transform-react-pure-annotations" "^7.12.1"

"@babel/[email protected]", "@babel/preset-typescript@^7.10.4":
"@babel/[email protected]", "@babel/preset-typescript@^7.10.4", "@babel/preset-typescript@^7.12.1":
version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.12.1.tgz#86480b483bb97f75036e8864fe404cc782cc311b"
integrity sha512-hNK/DhmoJPsksdHuI/RVrcEws7GN5eamhi28JkO52MqIxU8Z0QpmiSOQxZHWOHV7I3P4UjHV97ay4TcamMA6Kw==
Expand Down Expand Up @@ -4585,6 +4585,11 @@ async-listener@^0.6.0:
semver "^5.3.0"
shimmer "^1.1.0"

[email protected]:
version "0.9.2"
resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
integrity sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=

[email protected]:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
Expand Down Expand Up @@ -5191,6 +5196,11 @@ btoa-lite@^1.0.0:
resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337"
integrity sha1-M3dm2hWAEhD92VbCLpxokaudAzc=

btoa@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/btoa/-/btoa-1.2.1.tgz#01a9909f8b2c93f6bf680ba26131eb30f7fa3d73"
integrity sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==

[email protected]:
version "1.0.1"
resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819"
Expand Down Expand Up @@ -7177,6 +7187,13 @@ ejs@^2.6.1:
resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.7.4.tgz#48661287573dcc53e366c7a1ae52c3a120eec9ba"
integrity sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==

ejs@^3.1.5:
version "3.1.5"
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.5.tgz#aed723844dc20acb4b170cd9ab1017e476a0d93b"
integrity sha512-dldq3ZfFtgVTJMLjOe+/3sROTzALlL9E34V4/sDtUd/KlBSS0s6U1/+WPE1B4sj9CXHJpL1M6rhNJnc9Wbal9w==
dependencies:
jake "^10.6.1"

electron-to-chromium@^1.3.564, electron-to-chromium@^1.3.571:
version "1.3.584"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.584.tgz#506cf7ba5895aafa8241876ab028654b61fd9ceb"
Expand Down Expand Up @@ -7438,7 +7455,7 @@ escape-goat@^2.0.0:
resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675"
integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==

escape-html@~1.0.3:
escape-html@^1.0.3, escape-html@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=
Expand Down Expand Up @@ -8151,6 +8168,13 @@ file-uri-to-path@1, [email protected]:
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==

filelist@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.1.tgz#f10d1a3ae86c1694808e8f20906f43d4c9132dbb"
integrity sha512-8zSK6Nu0DQIC08mUC46sWGXi+q3GGpKydAG36k+JDba6VRpkevvOWUW5a/PhShij4+vHT9M+ghgG7eM+a9JDUQ==
dependencies:
minimatch "^3.0.4"

[email protected]:
version "6.1.0"
resolved "https://registry.yarnpkg.com/filesize/-/filesize-6.1.0.tgz#e81bdaa780e2451d714d71c0d7a4f3238d37ad00"
Expand Down Expand Up @@ -8945,7 +8969,7 @@ gulp-header@^1.7.1:
lodash.template "^4.4.0"
through2 "^2.0.0"

[email protected], gzip-size@^5.0.0:
[email protected], gzip-size@^5.0.0, gzip-size@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-5.1.1.tgz#cb9bee692f87c0612b232840a873904e4c135274"
integrity sha512-FNHi6mmoHvs1mxZAds4PpdCS6QG8B4C1krxJsMutgxl5t3+GlRTzzI3NEkifXx2pVsOvJdOGSmIgDhQ55FwdPA==
Expand Down Expand Up @@ -10348,6 +10372,16 @@ istanbul-reports@^3.0.2:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"

jake@^10.6.1:
version "10.8.2"
resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.2.tgz#ebc9de8558160a66d82d0eadc6a2e58fbc500a7b"
integrity sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==
dependencies:
async "0.9.x"
chalk "^2.4.2"
filelist "^1.0.1"
minimatch "^3.0.4"

jest-changed-files@^26.6.1:
version "26.6.1"
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-26.6.1.tgz#2fac3dc51297977ee883347948d8e3d37c417fba"
Expand Down Expand Up @@ -12817,7 +12851,7 @@ onetime@^5.1.0:
dependencies:
mimic-fn "^2.1.0"

open@^7.0.2:
open@^7.0.2, open@^7.1.0:
version "7.3.0"
resolved "https://registry.yarnpkg.com/open/-/open-7.3.0.tgz#45461fdee46444f3645b6e14eb3ca94b82e1be69"
integrity sha512-mgLwQIx2F/ye9SmbrUkurZCnkoXyXyu9EbHtJZrICjVAJfyMArdHp3KkixGdZx1ZHFPNIwl0DDM1dFFqXbTLZw==
Expand Down Expand Up @@ -15425,7 +15459,7 @@ rimraf@2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3:
dependencies:
glob "^7.1.3"

[email protected]:
[email protected], rimraf@~2.6.2:
version "2.6.3"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==
Expand Down Expand Up @@ -16001,6 +16035,24 @@ source-list-map@^2.0.0:
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"
integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==

source-map-explorer@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/source-map-explorer/-/source-map-explorer-2.5.0.tgz#42e12c76743e8a0ca0579d472ea5ba623e0d0498"
integrity sha512-kWhlt0celEwwuULIY+sRoZKibc/8/Ec4ckcKThDMQW3hT7KxReYW1XktwFJIbZ2VF9Yf/hA74bcoIZOSXXQIgQ==
dependencies:
btoa "^1.2.1"
chalk "^4.1.0"
convert-source-map "^1.7.0"
ejs "^3.1.5"
escape-html "^1.0.3"
glob "^7.1.6"
gzip-size "^5.1.1"
lodash "^4.17.20"
open "^7.1.0"
source-map "^0.7.3"
temp "^0.9.1"
yargs "^15.4.1"

source-map-resolve@^0.5.0, source-map-resolve@^0.5.2:
version "0.5.3"
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a"
Expand Down Expand Up @@ -16662,6 +16714,14 @@ temp-write@^3.4.0:
temp-dir "^1.0.0"
uuid "^3.0.1"

temp@^0.9.1:
version "0.9.4"
resolved "https://registry.yarnpkg.com/temp/-/temp-0.9.4.tgz#cd20a8580cb63635d0e4e9d4bd989d44286e7620"
integrity sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==
dependencies:
mkdirp "^0.5.1"
rimraf "~2.6.2"

tempy@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/tempy/-/tempy-0.3.0.tgz#6f6c5b295695a16130996ad5ab01a8bd726e8bf8"
Expand Down

0 comments on commit 99f00f2

Please sign in to comment.