Skip to content

Commit 456a35c

Browse files
authored
Merge pull request #4 from lihebi/back_to_webapp
Back to webapp
2 parents 003337e + fa25739 commit 456a35c

File tree

120 files changed

+17931
-50474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+17931
-50474
lines changed

README.md

Lines changed: 70 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,126 @@
1-
# CodePod: A Hierarchical IDE for Interactive Development at Scale
1+
# CodePod: coding on a canvas, organized.
22

33
![screenshot](./screenshot.png)
44

5-
# Installation
5+
# Development
66

7-
Binary release available for Linux and MacOS. See release page.
7+
```
8+
cd ./compose/dev/
9+
touch .env
10+
```
811

9-
For Debian/Ubuntu:
12+
Add your choice of secrets to the .env file (replace the placeholders):
1013

1114
```
12-
sudo dpkg -i codepod_0.1.0_amd64.deb
15+
POSTGRES_USER=<username>
16+
POSTGRES_PASSWORD=<password>
17+
POSTGRES_DB=<dbname>
18+
JWT_SECRET=<yoursecret>
1319
```
1420

15-
On Mac, use the `codepod_0.1.0_arm64.dmg` image (for M1 Macs with Apple Sillicon).
21+
Start the docker-compose stack:
22+
23+
```
24+
docker compose up -d
25+
```
1626

17-
You can run `codepod` either in application launcher or through the `codepod` command line tool.
27+
The docker-compose file declares a set of services:
1828

19-
# Install Jupyter kernels
29+
- api: the backend API server
30+
- ui: the frontend React app
31+
- db: postgres DB
32+
- prisma: prisma db viewer
33+
- nginx: reverse proxy to use nice URLs
2034

21-
These kernels are Jupyter kernels. CodePod should detect them and work as long
22-
as they are properly installed to work in Jupyter.
35+
You will need to perform a manual installation of node_modules into the api and
36+
ui containers. Attach a shell and run `yarn`. Without this, the initial api/ui
37+
contianers will not run. So you likely need to make changes to docker compose to
38+
do this (add `tty: true` and comment out commands line).
2339

24-
## python
40+
Then, initialize a DB by shell into the api container and run:
2541

2642
```
27-
sudo apt install python3
43+
npx prisma migrate dev --name init
2844
```
2945

30-
Install ipykernel:
46+
The nginx server expects `codepod.test` as the domain name. You can add a local
47+
DNS record to your /etc/hosts:
3148

3249
```
33-
python3 -m pip install ipykernel
34-
python3 -m ipykernel install --user
50+
10.43.1.148 codepod.test
3551
```
3652

37-
## racket
53+
This allows codepod.test to be resolved to your server machine. Then, go to
3854

39-
Install on Ubuntu:
55+
- http://codepod.test:3000 the web app
56+
- http://codepod.test:3000/graphql the grpahql explorer
57+
- http://codepod.test:5555 the prisma db viewer
4058

41-
```
42-
sudo add-apt-repository ppa:plt/racket
43-
sudo apt-get update
44-
sudo apt install racket
45-
```
59+
# Deployment
4660

47-
Install zmq:
61+
Build the docker images:
4862

4963
```
50-
brew install zmq
51-
sudo apt install libzmq5
64+
docker build -t lihebi/codepod-ui:v0.1.0 ./ui
65+
docker build -t lihebi/codepod-api:v0.1.0 ./api
66+
docker build -t lihebi/codepod_kernel_python:v0.1.0 ./api/kernels/python
5267
```
5368

69+
Push to registry:
70+
5471
```
55-
raco pkg install --auto iracket
56-
raco iracket install
72+
docker push lihebi/codepod-ui:v0.1.0
73+
docker push lihebi/codepod-api:v0.1.0
74+
docker push lihebi/codepod_kernel_python:v0.1.0
5775
```
5876

59-
On mac, zeromq lib cannot be found by racket due to [a known
60-
issue](https://github.com/rmculpepper/racket-zeromq/issues/6). To side-step it
61-
(replace the version numbers with your installation):
77+
Create a cloud VM with docker support. Add DNS from domain name to the cloud
78+
server. Setup TLS, e.g., `app-v1.codepod.io`:
6279

6380
```
64-
cp /opt/homebrew/Cellar/zeromq/4.3.4/lib/libzmq.5.dylib ~/Library/Racket/8.2/lib
81+
ufw allow 80
82+
certbot certonly --standalone
6583
```
6684

67-
## julia
68-
69-
Install julia from the official binaries. On Ubuntu:
85+
Clone this repo on the cloud VM, and go to the production folder:
7086

7187
```
72-
curl -O https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.4-linux-x86_64.tar.gz
73-
tar -xvzf julia-1.6.4-linux-x86_64.tar.gz
74-
sudo mv julia-1.6.4/ /opt/
75-
sudo ln -s /opt/julia-1.6.4/bin/julia /usr/local/bin/julia
88+
cd compose/prod
89+
touch .env
7690
```
7791

78-
<!--
92+
Add your choice of secrets to the .env file (replace the placeholders):
93+
7994
```
80-
julia
81-
]add add IJulia
82-
import IJulia
83-
IJulia.installkernel("Julia nodeps", "--depwarn=no")
95+
POSTGRES_USER=<username>
96+
POSTGRES_PASSWORD=<password>
97+
POSTGRES_DB=<dbname>
98+
JWT_SECRET=<yoursecret>
8499
```
85100

86-
Or just -->
101+
Change the domain name to your DNS in nginx.conf, e.g., `app-v1.codepod.io`:
87102

88-
Install kernel:
103+
Start the docker-compose stack:
89104

90105
```
91-
julia -e 'import Pkg; Pkg.add("IJulia"); using IJulia; installkernel("Julia nodeps", "--depwarn=no")'
106+
docker compose up -d
92107
```
93108

94-
## Javascript
109+
Then, initialize a DB by shell into the api container and run:
95110

96111
```
97-
npm install -g ijavascript
98-
ijsinstall
112+
npx prisma migrate dev --name init
99113
```
100114

101-
# Using remote runtime
102-
103-
In the runtime section in the sidebar, you can add a new runtime. For the runtime, you need to specify the two addresses: the websocket address for sending code to server, and the MQ address for receiving output. If MQ address is empty, the websocket will be used.
104-
105-
The default runtime is the local runtime, which is `localhost:14321`
106-
107-
To start the server, on the server machine, you need to setup the kernels. Then, you need to clone this repo, go into the cpkernel folder, and do:
108-
109-
1. `docker-compose up -d`. This will setup a rabbitmq server. The MQ address is `:15674`
110-
2. `npm run kernel-server`. This will run the server. The websocket address is `:14321`
111-
112-
So to use this server, enter:
113-
114-
- `<your-server-ip>:14321` for the socket address
115-
- `<your-server-ip>:15674` for the MQ address
116-
117-
We can spawn a docker container on the server for the kernels. However, it will be tricky to access files and install packages. One has to install packages for every restart of the kernel, and one has to mount a volume to exchange files between the server and the container. Thus we think it is a better experience to use the bare-metal server.
118-
119-
# Development Scripts
120-
121-
Develop
115+
Pull the kernel image:
122116

123117
```
124-
cd app
125-
npm run dev
118+
docker pull lihebi/codepod_kernel_python:v0.1.0
119+
docker tag lihebi/codepod_kernel_python:v0.1.0 codepod_kernel_python
126120
```
127121

128-
Build:
122+
Now go to
129123

130-
```
131-
cd app
132-
npm run build:all
133-
```
124+
- https://app-v1.codepod.io the web app
125+
126+
# (TODO) Architecture

api/.dockerignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

api/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
prisma/migrations
1+
dist/
2+
conns/conn-*.json
3+
prisma/migrations
4+
prisma/dev.db

api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16
1+
FROM node:18
22

33
WORKDIR /app
44
COPY package.json .

api/README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# CP Kernel
2+
3+
This is a package designed for code sharing between codepod API and electron server.
4+
5+
To use the kernel:
6+
If you use `yarn`, you can run `yarn add link:/path/to/cpkernel`. However, this will not work with npm. For npm, you need to run `npm link` in cpkernel folder to globally register the package, and run `npm link cpkernel` to link. This won't reflect in package.json.
7+
8+
Thus the ideal setup should be to add cpkernel to package.json, but not to install it. Instead, run `npm link cpkernel` during development.
9+
110
# CodePod Repo Server
211

312
# Using Prisma and PostgreSQL
@@ -37,7 +46,15 @@ migrate DB:
3746
npx prisma migrate dev --name init
3847
```
3948

40-
generate client (the migrate will run this, so no need anymore):
49+
create another migration with just a different name:
50+
51+
```
52+
prisma migrate dev --name added_job_title
53+
```
54+
55+
generate client (the migrate will run this, so no need anymore. But do not
56+
forget to do this after schema change, otherwise you'll end up with debugging
57+
strange errors):
4158

4259
```
4360
npx prisma generate
@@ -55,12 +72,11 @@ When I mess up with the database and want to start from scratch:
5572
npx prisma db push --preview-feature
5673
```
5774

58-
5975
## Building node-pty
6076

6177
Install nvm and node, yarn as usual. Running of `yarn` may fail (to build
6278
node-pty) due to missing development packages. On Ubuntu install:
6379

6480
```
6581
sudo apt install -y make python build-essential
66-
```
82+
```

api/db.js

Lines changed: 0 additions & 61 deletions
This file was deleted.
File renamed without changes.

api/jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2+
module.exports = {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
transform: {
6+
"^.+\\.ts?$": "ts-jest",
7+
},
8+
transformIgnorePatterns: ["<rootDir>/node_modules/"],
9+
};

0 commit comments

Comments
 (0)