1
+ #! /usr/bin/env bash
2
+
3
+ # This does a clean build from source of a clone
4
+ # of the cocalc repo where it is run from, deletes
5
+ # a lot that isn't needed for cocalc-project-runner, then
6
+ # tars it all up.
7
+ # **The result should be well under 50 MB.**
8
+ # See similar script in lite/bin/build-lite.sh
9
+
10
+ set -ev
11
+
12
+ VERSION=" $npm_package_version "
13
+ MACHINE=" $( uname -m) "
14
+ OS=" $( uname -s | tr ' [:upper:]' ' [:lower:]' ) "
15
+
16
+ NAME=cocalc-project-runner-$VERSION -$MACHINE -$OS
17
+ TMP=/tmp/$NAME
18
+ rm -rf " $TMP "
19
+ mkdir " $TMP "
20
+ TARGET=" $TMP /$NAME "
21
+ SRC=" $TARGET /src"
22
+
23
+ echo " Creating $TARGET "
24
+
25
+ BIN=` dirname " $( realpath $0 ) " `
26
+
27
+ git clone --depth=1 $BIN /../../../.. $TARGET
28
+
29
+ cd " $SRC " /packages
30
+ rm -rf database hub next server file-server lite
31
+
32
+ cd " $SRC "
33
+ ./workspaces.py install --exclude=database,hub,next,server,file-server,lite
34
+ ./workspaces.py build --exclude=database,hub,next,server,file-server,lite
35
+
36
+ cd " $SRC " /packages
37
+ rm -rf node_modules && pnpm install --prod --package-import-method=copy
38
+
39
+ rm -rf cdn frontend
40
+ rm -rf static/dist/* .map static/dist/embed-* .js
41
+
42
+ cd node_modules/.pnpm
43
+ rm -rf @next* next*
44
+ rm -rf googleapis* @google*
45
+ rm -rf zeromq* /node_modules/zeromq/prebuilds/* win*
46
+ rm -rf @types*
47
+ rm -rf @img*
48
+ rm -rf @rspack*
49
+ rm -rf rxjs*
50
+ rm -rf @zxcvbn* zod*
51
+ rm -rf jsdom*
52
+ rm -rf d3* @icons+material* katex* slate* react-highlight-words* codemirror* plotly* @plotly* mermaid* cytoscape-fcose* antd* pdfjs* maplibre* mapbox* three* @lumino* @mermaid* sass* webpack* @icons+material ' @napi-rs+canvas' *
53
+ rm -rf typescript* @tsd+typescript
54
+ rm -rf @cocalc+gcloud-pricing-calculator
55
+ rm -rf @maplibre* @orama*
56
+ rm -rf caniuse-lite@* cytoscape@* cytoscape-cose-bilkent@*
57
+ rm -rf refractor@* rc-picker@* @uiw+react-textarea-code-editor@* ajv@*
58
+ rm -rf langium@* moment@* react-dom@* @sinclair+typebox@* @xterm+addon-fit@* @xterm+addon-webgl@* @xterm+addon-web-links@* @xterm+xterm@* yjs@* zlibjs@* lodash-es@* @swc+helpers@*
59
+ rm -rf @jupyter*
60
+ rm -rf @asamuzakjp+css-color@
* csv-parse@
* elementary-circuits-directed-graph@
* jquery@
* [email protected] _react@
* * webpack
*
61
+ rm -rf @stripe*
62
+ rm -rf @dnd-kit*
63
+ rm -rf uglify-js*
64
+ rm -rf y-protocols*
65
+ rm -rf @nteract*
66
+ rm -rf dropzone@*
67
+ mkdir x
68
+ mv @ant-design* x
69
+ mv x/@ant-design+colors* .
70
+ rm -rf x
71
+
72
+ rm -rf js-tiktoken* gpt3-tokenizer* openai* @mistralai* @anthropic* @langchain*
73
+
74
+ if [ ` uname` == " Linux" ]; then
75
+ rm -rf zeromq* /node_modules/zeromq/build/darwin/
76
+ rm -rf zeromq* /node_modules/zeromq/build/win32/
77
+ fi
78
+
79
+ if [ ` uname` == " Darwin" ]; then
80
+ rm -rf zeromq* /node_modules/zeromq/build/linux/
81
+ rm -rf zeromq* /node_modules/zeromq/build/win32/
82
+ fi
83
+
84
+ if [ ` uname` == ' x86_64' ]; then
85
+ rm -rf zeromq* /node_modules/zeromq/build/* /arm64
86
+ fi
87
+ if [ ` uname` == ' arm64' ]; then
88
+ rm -rf zeromq* /node_modules/zeromq/build/* /x* 64
89
+ fi
90
+
91
+ # Upstream sqlite sources are ~10MB:
92
+ rm -rf better-sqlite3@* /node_modules/better-sqlite3/deps/sqlite3
93
+
94
+ cd " $SRC " /..
95
+ rm -rf * .md .github .git docs
96
+ mv src/packages/* .
97
+ rm -rf src
98
+ # remove rustic -- only needed for file server
99
+ rm -f backend/node_modules/.bin/rustic
100
+
101
+ cd $TMP
102
+ mkdir -p $BIN /../build/tarball
103
+ tar Jcvf $BIN /../build/tarball/$NAME .tar.xz $NAME
104
+
105
+ rm -rf " $TARGET "
0 commit comments