Skip to content

Commit f03960e

Browse files
committed
Update prod compose file.
1 parent c4debcc commit f03960e

File tree

6 files changed

+83
-167
lines changed

6 files changed

+83
-167
lines changed

README.md

Lines changed: 64 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,116 @@
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
6-
7-
Binary release available for Linux and MacOS. See release page.
8-
9-
For Debian/Ubuntu:
5+
# Development
106

117
```
12-
sudo dpkg -i codepod_0.1.0_amd64.deb
8+
cd ./compose/dev/
9+
touch .env
1310
```
1411

15-
On Mac, use the `codepod_0.1.0_arm64.dmg` image (for M1 Macs with Apple Sillicon).
16-
17-
You can run `codepod` either in application launcher or through the `codepod` command line tool.
18-
19-
# Install Jupyter kernels
20-
21-
These kernels are Jupyter kernels. CodePod should detect them and work as long
22-
as they are properly installed to work in Jupyter.
23-
24-
## python
12+
Add your choice of secrets to the .env file (replace the placeholders):
2513

2614
```
27-
sudo apt install python3
15+
POSTGRES_USER=<username>
16+
POSTGRES_PASSWORD=<password>
17+
POSTGRES_DB=<dbname>
18+
JWT_SECRET=<yoursecret>
2819
```
2920

30-
Install ipykernel:
21+
Start the docker-compose stack:
3122

3223
```
33-
python3 -m pip install ipykernel
34-
python3 -m ipykernel install --user
24+
docker compose up -d
3525
```
3626

37-
## racket
27+
The docker-compose file declares a set of services:
3828

39-
Install on Ubuntu:
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
4034

41-
```
42-
sudo add-apt-repository ppa:plt/racket
43-
sudo apt-get update
44-
sudo apt install racket
45-
```
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).
4639

47-
Install zmq:
40+
Then, initialize a DB by shell into the api container and run:
4841

4942
```
50-
brew install zmq
51-
sudo apt install libzmq5
43+
npx prisma migrate dev --name init
5244
```
5345

46+
The nginx server expects `codepod.test` as the domain name. You can add a local
47+
DNS record to your /etc/hosts:
48+
5449
```
55-
raco pkg install --auto iracket
56-
raco iracket install
50+
10.43.1.148 codepod.test
5751
```
5852

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):
53+
This allows codepod.test to be resolved to your server machine. Then, go to
6254

63-
```
64-
cp /opt/homebrew/Cellar/zeromq/4.3.4/lib/libzmq.5.dylib ~/Library/Racket/8.2/lib
65-
```
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
6658

67-
## julia
59+
# (TODO) Deployment
6860

69-
Install julia from the official binaries. On Ubuntu:
61+
Build the docker images:
7062

7163
```
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
64+
docker build -t lihebi/codepod-ui:v0.1.0 ./ui
65+
docker build -t lihebi/codepod-api:v0.1.0 ./api
7666
```
7767

78-
<!--
68+
Push to registry:
69+
7970
```
80-
julia
81-
]add add IJulia
82-
import IJulia
83-
IJulia.installkernel("Julia nodeps", "--depwarn=no")
71+
docker push lihebi/codepod-ui:v0.1.0
72+
docker push lihebi/codepod-api:v0.1.0
8473
```
8574

86-
Or just -->
87-
88-
Install kernel:
75+
Create a cloud VM with docker support. Setup TLS:
8976

9077
```
91-
julia -e 'import Pkg; Pkg.add("IJulia"); using IJulia; installkernel("Julia nodeps", "--depwarn=no")'
78+
sudo certbot certonly
9279
```
9380

94-
## Javascript
81+
Clone this repo on the cloud VM, and go to the production folder, change the
82+
domain name to e.g. app-v0_1_0.codepod.io:
9583

9684
```
97-
npm install -g ijavascript
98-
ijsinstall
85+
cd compose/prod
86+
touch .env
9987
```
10088

101-
# Using remote runtime
89+
Add your choice of secrets to the .env file (replace the placeholders):
10290

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
91+
```
92+
POSTGRES_USER=<username>
93+
POSTGRES_PASSWORD=<password>
94+
POSTGRES_DB=<dbname>
95+
JWT_SECRET=<yoursecret>
96+
```
12097

121-
Develop
98+
Start the docker-compose stack:
12299

123100
```
124-
cd app
125-
npm run dev
101+
docker compose up -d
126102
```
127103

128-
Build:
104+
Then, initialize a DB by shell into the api container and run:
129105

130106
```
131-
cd app
132-
npm run build:all
107+
npx prisma migrate dev --name init
133108
```
109+
110+
Now add DNS from domain name to the cloud server. Now go to
111+
112+
- http://codepod.test:3000 the web app
113+
- http://codepod.test:3000/graphql the grpahql explorer
114+
- http://codepod.test:5555 the prisma db viewer
115+
116+
# (TODO) Architecture

api/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:18
2+
3+
WORKDIR /app
4+
COPY package.json .
5+
RUN yarn
6+
7+
COPY . .
8+
# this will modify node_modules/@prisma/client
9+
RUN yarn run prisma generate
10+
11+
CMD ["yarn", "dev"]

api/docker-compose.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

compose/prod/docker-compose.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ services:
1313
- codepod-db-prod:/var/lib/postgresql/data
1414

1515
api:
16-
image: codepod-api:v0.0.3.1
16+
image: lihebi/codepod-api:v0.1.0
1717
depends_on:
1818
- rabbitmq
1919
restart: always
2020
volumes:
2121
- /var/run/docker.sock:/var/run/docker.sock
22-
- git-data-prod:/srv/git
2322
command: yarn start
2423
environment:
2524
DATABASE_URL: "postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?schema=public"
2625
JWT_SECRET: ${JWT_SECRET}
2726
KERNEL_NETWORK: "codepod-prod"
2827

2928
ui:
30-
image: codepod-ui:v0.0.3.1
29+
image: lihebi/codepod-ui:v0.1.0
3130
restart: always
3231
# FIXME this takes a lot of time on startup
3332
command: yarn start
@@ -38,12 +37,6 @@ services:
3837
volumes:
3938
- ./rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
4039

41-
git-http:
42-
restart: always
43-
build: ../dev/docker-git-http
44-
volumes:
45-
- git-data-prod:/var/lib/git
46-
4740
# docker-compose up -d --build --force-recreate --no-deps nginx
4841
nginx:
4942
image: nginx:1.15-alpine
@@ -73,17 +66,9 @@ services:
7366
depends_on:
7467
- ui
7568

76-
# docker run -it --rm --network host -v $(pwd)/frpc.ini:/etc/frp/frpc.ini snowdreamtech/frpc
77-
frpc:
78-
image: snowdreamtech/frpc
79-
restart: always
80-
volumes:
81-
- ./frpc.ini:/etc/frp/frpc.ini
82-
network_mode: "host"
8369

8470
volumes:
8571
codepod-db-prod:
86-
git-data-prod:
8772

8873
networks:
8974
default:

compose/prod/nginx/nginx.conf

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set $domain app-v0_1_0.codepod.io
12

23
# By default, server /var/www/html
34
# Need to mount it! I prefer not to mount it by default so that I don't server
@@ -14,7 +15,7 @@ server {
1415
listen 80;
1516
listen [::]:80;
1617

17-
server_name codepod.io www.codepod.io;
18+
server_name $domain;
1819

1920
return 301 https://$host$request_uri;
2021

@@ -35,12 +36,12 @@ server {
3536
server {
3637
listen 443 ssl http2;
3738
listen [::]:443 ssl http2;
38-
server_name codepod.io www.codepod.io;
39+
server_name $domain;
3940

4041
server_tokens off;
4142

42-
ssl_certificate /etc/letsencrypt/live/codepod.io/fullchain.pem;
43-
ssl_certificate_key /etc/letsencrypt/live/codepod.io/privkey.pem;
43+
ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem;
44+
ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem;
4445

4546
location / {
4647
proxy_pass http://ui:3000;
@@ -55,49 +56,3 @@ server {
5556
proxy_pass http://api:4000;
5657
}
5758
}
58-
59-
60-
server {
61-
listen 80;
62-
listen [::]:80;
63-
server_name git.codepod.io;
64-
return 301 https://$host$request_uri;
65-
}
66-
67-
server {
68-
listen 443 ssl http2;
69-
listen [::]:443 ssl http2;
70-
server_name git.codepod.io;
71-
ssl_certificate /etc/letsencrypt/live/git.codepod.io/fullchain.pem;
72-
ssl_certificate_key /etc/letsencrypt/live/git.codepod.io/privkey.pem;
73-
location / {
74-
proxy_pass http://git-http:80;
75-
}
76-
}
77-
78-
79-
server {
80-
listen 80;
81-
listen [::]:80;
82-
server_name mq.codepod.io;
83-
return 301 https://$host$request_uri;
84-
}
85-
86-
server {
87-
listen 443;
88-
listen [::]:443;
89-
server_name mq.codepod.io;
90-
ssl_certificate /etc/letsencrypt/live/mq.codepod.io/fullchain.pem;
91-
ssl_certificate_key /etc/letsencrypt/live/mq.codepod.io/privkey.pem;
92-
# ssl_certificate /etc/nginx/conf.d/cfpub.pem;
93-
# ssl_certificate_key /etc/nginx/conf.d/cfpriv.pem;
94-
location / {
95-
proxy_pass http://rabbitmq:15672;
96-
}
97-
location /ws {
98-
proxy_pass http://rabbitmq:15674;
99-
proxy_http_version 1.1;
100-
proxy_set_header Upgrade $http_upgrade;
101-
proxy_set_header Connection "upgrade";
102-
}
103-
}

ui/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 package.json

0 commit comments

Comments
 (0)