You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use the variable `CODEPOD_ROOT` to refer to the root folder of the CodePod.
44
+
If you just ran the command above, then `CODEPOD_ROOT` is the folder you just cloned.
45
+
46
+
Now enter the `CODEPOD_ROOT/compose` folder:
47
+
48
+
```bash
49
+
cd codepod/compose
50
+
```
51
+
52
+
The docker compose files are in `CODEPOD_ROOT/compose/dev` folder. The `dev` stack mounts the
54
53
`src` folder, so that you can edit the files on your local computer, and let the
55
54
node.js process inside the container do the compiling and hot-reloading.
56
55
57
56
To install docker-compose, follow the official [Docker documentation](https://docs.docker.com/compose/install/linux/).
58
57
59
58
## .env file
60
59
61
-
First, create a `dev/.env` file with the following content (leave as is or change the value to
60
+
Now enter the `CODEPOD_ROOT/compose/dev` folder
61
+
62
+
63
+
```bash
64
+
cd dev
65
+
```
66
+
67
+
and create a `.env` file with the following content (leave as is or change the value to
62
68
whatever you want).
63
69
64
70
```properties
71
+
# Mandatory settings
65
72
POSTGRES_USER=myusername
66
73
POSTGRES_PASSWORD=mypassword
67
74
POSTGRES_DB=mydbname
68
75
JWT_SECRET=mysupersecretjwttoken
69
76
77
+
# optional settings
70
78
GOOGLE_CLIENT_ID=<google oauth client id>
71
79
72
80
EXPORT_AWS_S3_REGION=us-west-1
@@ -80,37 +88,59 @@ Optional:
80
88
- Leave the `GOOGLE_CLIENT_ID` empty if you do not need the OAuth provided by Google.
81
89
-`EXPORT_AWS_S3_XXX` are used for file export. You could leave it empty if you don't use it.
82
90
83
-
## Start the stack
91
+
## Starting the stack
92
+
93
+
From the `CODEPOD_ROOT/compose/dev` folder, run:
84
94
85
95
```bash
86
-
cd dev
87
96
docker compose up -d
88
97
```
89
98
90
-
You need to initialized the database first before starting the stack. See below.
99
+
If you this is your first time setting up CodePod, or the database schema has been updated (which you can tell from errors), you will also need to [initalize database tables](#initializing-the-database).
91
100
92
101
Wait a few minutes for the package installation and compilation. Once the `ui` and
93
102
`api` containers are ready, go to `http://localhost:80` to see the app.
94
103
95
104
-`http://localhost:80/graphql`: Apollo GraphQL explorer for the backend APIs
96
105
-`http://prisma.127.0.0.1.sslip.io`: Prisma Studio for viewing and debugging the database.
97
106
98
-
## Initialize the database
107
+
### Initializing database tables
108
+
109
+
To initialize or update the database schema, open a shell into the API container (by default called `dev-api-1` but please use `docker ps` to confirm):
110
+
111
+
```bash
112
+
docker exec -it dev-api-1 /bin/bash
113
+
```
114
+
115
+
and then **from the shell of the API container** run:
99
116
100
-
If this is your first time running it, you would need to initialize the database as it's empty. To do that, open a shell into the API container and run:
101
117
102
-
```bash
103
-
npx prisma migrate dev
104
-
```
105
118
106
-
This command is also needed after the database schema is changed. The protocol is:
119
+
> Known issues: if you get the error below during the migration,
The schema change along with this migration need to be checked in to git.
113
-
- Another developer pulls the change, then running the `npx prisma migrate dev` (in the api container's shell) to apply the schema change.
134
+
### Preparing for database migration
135
+
136
+
If you are a developer who wants to change the database schema for adding a feature, you can update the schema file `CODEPOD_ROOT/api/prisma/schema.prisma` and then run
137
+
138
+
```bash
139
+
npx prisma migrate dev --name add_a_new_field
140
+
```
141
+
142
+
to generate a migration, like [this](./api/prisma/migrations/20221206194247_add_google_login/migration.sql).
143
+
The schema change along with this migration need to be checked in (add, commit, and push) to git.
114
144
115
145
## Auto-completion & Linting
116
146
@@ -123,3 +153,60 @@ cd ./api/
123
153
# Run 'npm install' instead if you are using npm
124
154
yarn
125
155
```
156
+
157
+
## Starting two stacks simultaneously
158
+
159
+
It might be necessary to create two Docker stacks for two verions of CodePod, respectively. For example, you might want to test the new version of CodePod while keeping the old version running.
160
+
161
+
Because Docker uses the folder name as the default suffix in container names, these two stacks may conflict with each other. To avoid this, you can use the `COMPOSE_PROJECT_NAME` environment variable to set a prefix for the container names. For example, you can set `COMPOSE_PROJECT_NAME=codepod-v2` in the `CODEPOD_ROOT/compose/dev/.env` file of the new stack, and then [start](#starting-the-stack) the new stack.
162
+
163
+
The two stacks also may share the same network ports due to the same configuration files used. To set the ports, search for the following lines in `CODEPOD_ROOT/compose/dev/nginx.conf` (two occurences of the two lines in the file) file of the new stack:
164
+
165
+
```yaml
166
+
listen 80;
167
+
listen [::]:80;
168
+
```
169
+
170
+
and the following section in the `CODEPOD_ROOT/compose/dev/compose.yml` file of the new stack:
171
+
172
+
```
173
+
nginx:
174
+
image: nginx:alpine
175
+
ports:
176
+
- 80:80
177
+
volumes:
178
+
- ./nginx.conf:/etc/nginx/conf.d/default.conf
179
+
```
180
+
181
+
and replace the default port number 80 to a new port number. For example, you can set the port number to 8080 for all occurences of 80.
182
+
183
+
Also, comment out the port section of the `ui` container in `CODEPOD_ROOT/compose/dev/compose.yml` as:
184
+
185
+
```
186
+
ui:
187
+
image: node:18
188
+
working_dir: /app
189
+
# ports:
190
+
# For react hot-reloading in development.
191
+
# - 3000:3000
192
+
```
193
+
194
+
195
+
Then, you can access the new stack at `http://localhost:8080`.
196
+
197
+
198
+
# Citation
199
+
200
+
https://arxiv.org/abs/2301.02410
201
+
202
+
```
203
+
@misc{https://doi.org/10.48550/arxiv.2301.02410,
204
+
doi = {10.48550/ARXIV.2301.02410},
205
+
url = {https://arxiv.org/abs/2301.02410},
206
+
author = {Li, Hebi and Bao, Forrest Sheng and Xiao, Qi and Tian, Jin},
207
+
title = {Codepod: A Namespace-Aware, Hierarchical Jupyter for Interactive Development at Scale},
0 commit comments