Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit e119516

Browse files
authored
chore: monorepo!
chore: monorepo!
2 parents 41dbdc5 + 0fb796c commit e119516

File tree

2,097 files changed

+11018
-40
lines changed

Some content is hidden

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

2,097 files changed

+11018
-40
lines changed

README.md

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,25 @@
1+
# :elephant: PostgreSQL, in your browser
12

2-
# pg-wasm
3-
4-
Run [PostgreSQL](https://www.postgresql.org/) in the browser:
5-
6-
![Screenshot 2022-08-29 at 14 58 13](https://user-images.githubusercontent.com/20510494/187206593-81811973-f2b2-45be-a5a2-d6c9cc57d973.png)
7-
8-
# Getting started
3+
## :zap: Getting started
94

105
```bash
11-
npx serve
12-
┌────────────────────────────────────────────────────┐
13-
│ │
14-
│ Serving!
15-
│ │
16-
│ - Local: http://localhost:3000 │
17-
│ - On Your Network: http://172.17.184.115:3000 │
18-
│ │
19-
│ Copied local address to clipboard!
20-
│ │
21-
└────────────────────────────────────────────────────┘
6+
cd pg-wasm && npx serve
227
```
238

24-
Tada! You should see a working psql terminal
25-
26-
# Boot and save a new snapshot
9+
Go to http://localhost:3000 and have fun!
2710

28-
1. Place the `filesystem` folder produced by https://github.com/jgoux/pg-browser in the root of the repository
11+
## :brain: Architecture
2912

30-
2. Search in the `filesystem/filesystem.json` file for the `bzImage` corresponding `.bin` filename and replace its value in [index.html](index.html#L39)
13+
> TODO
3114
32-
2. Go the `http://localhost:3000?boot=true`
15+
## :eyes: Going further
3316

34-
3. Once the boot is completed, clear the cache running `echo 3 > /proc/sys/vm/drop_caches && reset` and click the "Save state to file" button
17+
- [pg-wasm](/packages/pg-wasm/README.md)
18+
- [Buildroot](/packages/buildroot/README.md)
3519

36-
4. Put the state file into the `state/` folder and compress it:
37-
38-
```bash
39-
zstd --ultra -22 state/state.bin && rm state/state.bin
40-
```
20+
## :clap: Aknowledgements
4121

42-
5. Go to `http://localhost:3000`, the boot should be instant :rocket:
22+
- [v86](https://github.com/copy/v86) which is **the** emulator for running x86 operating systems in the browser, without it none of the following projects would be possible
23+
- [crunchydata playground](https://www.crunchydata.com/developers/playground) for leading the way and showing the world that it was possible to run PostgreSQL in the browser
24+
- [browser-shell](https://github.com/humphd/browser-shell) which was already way ahead of its time, especially on the filesystem part
25+
- [browser-linux](https://github.com/Darin755/browser-linux) for showing us how we can make the pieces fit together

filesystem/filesystem.json

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

packages/buildroot/.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/*
2+
.gitignore
3+
LICENSE
4+
README.md

packages/buildroot/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

packages/buildroot/Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM rastasheep/ubuntu-sshd:18.04
2+
3+
# Buildroot version to use
4+
ARG BUILD_ROOT_RELEASE=2022.08-rc1
5+
6+
# Root password for SSH
7+
ARG ROOT_PASSWORD=browser-vm
8+
9+
# Setup SSH (for Windows users) and prepare apt-get
10+
RUN echo 'root:${ROOT_PASSWORD}' | chpasswd; \
11+
# Install all Buildroot deps
12+
sed -i 's|deb http://us.archive.ubuntu.com/ubuntu/|deb mirror://mirrors.ubuntu.com/mirrors.txt|g' /etc/apt/sources.list; \
13+
dpkg --add-architecture i386; \
14+
rm -rf /var/lib/apt/lists/*; \
15+
apt-get -q update;
16+
17+
# Install all Buildroot deps and prepare buildroot
18+
WORKDIR /root
19+
20+
RUN DEBIAN_FRONTEND=noninteractive apt-get -q -y install \
21+
bc \
22+
build-essential \
23+
bzr \
24+
cpio \
25+
cvs \
26+
git \
27+
unzip \
28+
wget \
29+
libc6:i386 \
30+
libncurses5-dev \
31+
libssl-dev \
32+
rsync; \
33+
wget -c http://buildroot.org/downloads/buildroot-${BUILD_ROOT_RELEASE}.tar.gz; \
34+
tar axf buildroot-${BUILD_ROOT_RELEASE}.tar.gz;
35+
36+
# configure the locales
37+
ENV LANG='C' \
38+
LANGUAGE='en_US:en' \
39+
LC_ALL='C' \
40+
NOTVISIBLE="in users profile" \
41+
TERM=xterm
42+
43+
# Buildroot will place built artifacts here at the end.
44+
VOLUME /build
45+
46+
WORKDIR /root/buildroot-${BUILD_ROOT_RELEASE}
47+
48+
COPY config /config
49+
50+
RUN cp -r /config/* /config/.config .
51+
52+
ENTRYPOINT ["bash"]

packages/buildroot/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Buildroot
2+
3+
> Buildroot configuration to build a v86 compatible minimal Linux system containing PostgreSQL
4+
5+
## Getting started
6+
7+
The goal of this build process is to produce a `filesystem` folder containing a full Linux filesystem that will be mounted and served by v86
8+
9+
1. Build and run the container to execute Buildroot
10+
11+
```bash
12+
./build.sh
13+
```
14+
15+
1.1. If you need to refresh the Buildroot configuration files from the host, execute this command [OPTIONAL]:
16+
17+
```bash
18+
cp -r /config/* /config/.config .
19+
```
20+
21+
1.2. Tweak the configuration and save it back to the host [OPTIONAL]:
22+
23+
```bash
24+
# Linux system config
25+
# Launch menuconfig
26+
make menuconfig
27+
# Save the changes back to the host
28+
cp .config /pg-wasm/.config
29+
30+
# Linux kernel config
31+
# IMPORTANT: If it's the first time you run this command,
32+
# exit the linux-menuconfig when it opens and copy the host file by running
33+
# cp /pg-wasm/board/pg-wasm/linux.conf ./output/build/linux-5.17.15/.config
34+
# then you can go back to "make linux-menuconfig" to edit this configuration
35+
# Launch menuconfig
36+
make linux-menuconfig
37+
# Save the changes back to the host
38+
cp output/build/linux-5.17.15/.config /pg-wasm/board/pg-wasm/linux.conf
39+
```
40+
41+
2. Build the `filesystem` folder:
42+
43+
```bash
44+
make
45+
```
46+
47+
...
48+
49+
At this point you can go for a walk, it will take a bit of time :turtle:
50+
51+
...
52+
53+
The `filesystem` folder should be available on the host at `build/filesystem`

packages/buildroot/build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
docker build -t buildroot .
2+
3+
docker run \
4+
--rm \
5+
-v $PWD/tools:/tools \
6+
-v $PWD/build:/build \
7+
-v $PWD/config/config \
8+
-ti \
9+
--platform linux/amd64 \
10+
buildroot

0 commit comments

Comments
 (0)