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
Create standardized Docker development environment via .devcontainer (sql-js#445)
* Initial default .devcontainer and Dockerfile created
* Install EMSDK and Chrome dependencies in the Dockerfile
* Move Contributing/Compiling instructions to Contributing.md
* Start worker test in Puppeteer without Chrome sandbox when running in Docker
* Add `clean` package script and express `rebuild` script in terms of npm scripts
This aims to express all build tasks via npm scripts via make commands, rather than expressing some scripts as npm scripts and others in terms of make.
* Pin EMSDK to 2.0.15
* First attempt at Github action building inside of Docker container
* Switch cmd to entrypoint
* Create an entrypoint.sh for the Github build-sqljs action
* remove comments
* Make action script executable
* Set correct path in docker image
Co-authored-by: lovasoa <[email protected]>
# BEGIN Standard MS Devcontainer for Typescript-Node
6
+
7
+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/typescript-node/.devcontainer/base.Dockerfile
8
+
# [Choice] Node.js version: 14, 12, 10
9
+
ARG VARIANT="14-buster"
10
+
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
11
+
12
+
# [Optional] Uncomment if you want to install an additional version of node using nvm
13
+
# ARG EXTRA_NODE_VERSION=10
14
+
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
15
+
16
+
# [Optional] Uncomment if you want to install more global node packages
17
+
# RUN su node -c "npm install -g <your-package-list -here>"
18
+
19
+
# END Standard MS Devcontainer for Typescript-Node
# Here we install all of the packages depended upon by Chrome (that Puppeteer will use for headless tests).
69
+
# We could also take a page from https://github.com/buildkite/docker-puppeteer/blob/master/Dockerfile instead,
70
+
# and install the latest stable version of Chrome to get the right dependencies, but that version changes over time,
71
+
# so the stable version of Chrome and the version installed by Puppeteer might diverge over time.
72
+
# It also means they end up having Chrome downloaded and installed twice.
73
+
# We could install the particular version of Chrome that our version of Puppeteer would use and then tell Puppeteer not to download its own version of Chrome,
74
+
# but then we'd have to rebuild our Docker container every time we revved Puppeteer, and that feels fiddly too.
75
+
# For all of these reasons, it seems safer to simply install the explicit list packages depended upon by Chrome, assume that's unlikely to change
# We set this env variable (RUN_WORKER_TEST_WITHOUT_PUPPETEER_SANDBOX=1) this to tell our sql.js test harness to run Puppeteer without the sandbox.
121
+
# Otherwise, when we instantiate Puppeteer, we get this error:
122
+
# Puppeteer can't start due to a sandbox error. (Details follow.)
123
+
# [0321/173044.694524:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
General consumers of this library don't need to read any further. (The compiled files are available via the [release page](https://github.com/sql-js/sql.js/releases).)
5
+
6
+
If you want to compile your own version of SQLite for WebAssembly, or want to contribute to this project, read on.
7
+
8
+
## Setting up your Development Environment
9
+
10
+
### Containerized Development Environment (Recommended)
11
+
12
+
This project defines a standardized development environment using Docker (and the .devcontainer spec in particular). This allows for anyone on any platform to get up and running quickly. (VSCode is not technically required to make use of this standardized environment, but it makes containerized development so seamless that the non-VSCode path is not currently documented here.)
13
+
14
+
Standardizing our development environment has numerous benefits:
15
+
- Allows anyone on ANY platform (Linux, Mac, and Windows) to contribute or compile their own build.
16
+
- It's quicker and easier for any contributor to dive in and fix issues.
17
+
- (Practically) eliminates configuration bugs that are difficult for maintainers to reproduce. Also known as "works on my machine" issues.
18
+
- Allows us to write our scripts assuming that they're _always_ running in a single known environment of a single, known platform.
19
+
- Ensure that all contributors use a known, standardized installation of EMSDK.
20
+
- Allows for a more clearly documented process for updating the EMSDK to a new version.
21
+
- End-Users that simply want to compile and install their own version of SQLite don't have to bother with EMSDK installation in their particular environment.
22
+
23
+
To get started:
24
+
25
+
1. Follow the [Installation Steps for Containerized Development in VSCode](https://code.visualstudio.com/docs/remote/containers#_installation). This includes installing Docker, VSCode, and the [Remote Development extension pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) for VSCode)
26
+
2. Clone this repository
27
+
3. Open the repository folder in VSCode. It will detect the presence of a .devcontainer and prompt you: "Folder contains a Dev Container configuration file. Reopen folder to develop in a container." Click "Reopen in container"
28
+
29
+
You're now ready to test the dev environment:
30
+
4. Click on Terminal->New Terminal to be dropped into a terminal inside the dev environment.
31
+
5. Run `$ npm install` to install the required modules
32
+
6. Run `$ npm test` to ensure all tests pass
33
+
7. Run `$ npm rebuild` to re-compile the project from scratch (using the version of EMSDK installed in the container).
34
+
8. Run `$ npm test` to ensure all tests pass after said rebuild
35
+
36
+
You're now ready for development!
37
+
38
+
### Host-based configuration (Not recommended)
39
+
40
+
If you're on a Mac or Linux-based host machine, you can install and use the EMSDK directly to perform a build.
41
+
Note that if you run into bugs with this configuration, we highly encourage you to use the containerized development environment instead, as detailed above.
42
+
43
+
Instructions:
44
+
45
+
1.[Install the EMSDK](https://emscripten.org/docs/getting_started/downloads.html)
46
+
2. Clone this repository
47
+
3. Run `$ npm install` to install the required modules
48
+
4. Run `$ npm test` to ensure all tests pass
49
+
5. Run `$ npm rebuild` to re-compile the project from scratch (using the version of EMSDK installed in the container).
50
+
6. Run `$ npm test` to ensure all tests pass after said rebuild
51
+
52
+
## Compiling SQLite with different options
53
+
54
+
In order to enable extensions like JSON1 or FTS5, change the CFLAGS in the [Makefile](Makefile) and run `npm run rebuild`:
Copy file name to clipboardexpand all lines: README.md
+5-18
Original file line number
Diff line number
Diff line change
@@ -322,21 +322,8 @@ For each [release](https://github.com/sql-js/sql.js/releases/), you will find a
322
322
-`sql-asm-debug.js` : The _Debug_ asm.js version of Sql.js. Use this for local development.
323
323
-`worker.*` - Web Worker versions of the above libraries. More limited API. See [examples/GUI/gui.js](examples/GUI/gui.js) for a good example of this.
324
324
325
-
## Compiling
326
-
327
-
- Install the EMSDK, [as described here](https://emscripten.org/docs/getting_started/downloads.html)
328
-
- Run `npm run rebuild`
329
-
330
-
In order to enable extensions like FTS5, change the CFLAGS in the [Makefile](Makefile) and rebuild:
331
-
332
-
```diff
333
-
CFLAGS = \
334
-
-O2 \
335
-
-DSQLITE_OMIT_LOAD_EXTENSION \
336
-
-DSQLITE_DISABLE_LFS \
337
-
-DSQLITE_ENABLE_FTS3 \
338
-
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
339
-
+ -DSQLITE_ENABLE_FTS5 \
340
-
-DSQLITE_ENABLE_JSON1 \
341
-
-DSQLITE_THREADSAFE=0
342
-
```
325
+
## Compiling/Contributing
326
+
327
+
General consumers of this library don't need to read any further. (The compiled files are available via the [release page](https://github.com/sql-js/sql.js/releases).)
328
+
329
+
If you want to compile your own version of SQLite for WebAssembly, or want to contribute to this project, see [CONTRIBUTING.md](docs/CONTRIBUTING.md).
Copy file name to clipboardexpand all lines: package.json
+2-1
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,8 @@
20
20
"main": "./dist/sql-wasm.js",
21
21
"scripts": {
22
22
"build": "make",
23
-
"rebuild": "make clean && make",
23
+
"rebuild": "npm run clean && npm run build",
24
+
"clean": "make clean",
24
25
"test": "npm run lint && npm run test-asm && npm run test-asm-debug && npm run test-wasm && npm run test-wasm-debug && npm run test-asm-memory-growth",
// That seemed kinda complicated, so I'm working around it more quickly/straightforwardly by looking for an env variable we set in the Docker fil `RUN_WORKER_TEST_WITHOUT_PUPPETEER_SANDBOX`.
console.warn("Puppeteer can't start due to a sandbox error. (Details follow.)\nFor a quick, but potentially dangerous workaround, you can set the environment variable 'RUN_WORKER_TEST_WITHOUT_PUPETEER_SANDBOX=1'.\nYou can also simply run this test in the Docker container defined in .devcontainer/Dockerfile.");
46
+
}
47
+
}
48
+
// If we're here, we couldn't get out of this cleanly. Re-throw
0 commit comments