Skip to content

Commit 680f080

Browse files
committed
build: add config for running web-forms via containers
1 parent 99295eb commit 680f080

File tree

6 files changed

+76
-1
lines changed

6 files changed

+76
-1
lines changed

contrib/containers/Containerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM emscripten/emsdk:4.0.4 AS emsdk
2+
3+
4+
# We can't use node bundled in emsdk img as v20.18.0 is incompatible with pinned engines
5+
FROM docker.io/node:22-slim
6+
WORKDIR /app
7+
COPY --from=emsdk /emsdk /emsdk
8+
ENV PATH=$PATH:/emsdk:/emsdk/upstream/emscripten
9+
RUN apt-get update --quiet \
10+
&& DEBIAN_FRONTEND=noninteractive \
11+
apt-get install -y --quiet --no-install-recommends \
12+
"python3" \
13+
&& rm -rf /var/lib/apt/lists/*
14+
COPY . .
15+
RUN corepack enable && corepack install
16+
RUN yarn install
17+
# Build packages as a sanity check
18+
RUN yarn workspace @getodk/tree-sitter-xpath build
19+
RUN yarn workspace @getodk/xpath build
20+
RUN yarn workspace @getodk/xforms-engine build

contrib/containers/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Running Web Forms Via Docker
2+
3+
Running web-forms locally requires two things:
4+
- As of 05/03/2025, web-forms requires the compiled WASM bundle for the `tree-sitter` package.
5+
- Building this requires emscripten or docker installed on your machine, see [issue #41](https://github.com/getodk/web-forms/issues/41).
6+
- The xlsform-online service running on a local port.
7+
8+
A simple alternative to building and configuring these manually is to run web-forms via docker.
9+
10+
## Building The Images
11+
12+
```bash
13+
docker compose -f contrib/containers/compose.yaml build
14+
```
15+
16+
## Running Web Forms
17+
18+
```bash
19+
docker compose -f contrib/containers/compose.yaml up -d
20+
```
21+
22+
Access web forms preview on: http://localhost:3221

contrib/containers/compose.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
web-forms:
3+
image: ghcr.io/getodk/web-forms:main
4+
build:
5+
context: ../..
6+
dockerfile: contrib/containers/Containerfile
7+
volumes:
8+
- ../../packages:/app/packages
9+
ports:
10+
- "${WEB_FORMS_PORT:-3221}:3221"
11+
command: yarn workspace @getodk/web-forms dev
12+
13+
xlsform-online:
14+
image: ghcr.io/getodk/xlsform-online:master
15+
build:
16+
context: https://github.com/getodk/xlsform-online.git#master
17+
environment:
18+
DJANGO_SECRET_KEY: xxxxxxxxxxxxxxxxxxx
19+
DJANGO_TMP_HOME: /tmp_home
20+
DJANGO_PERSISTENT_HOME: /persistent_home
21+
DJANGO_CORS_ALLOWED_ORIGIN: http://localhost:${WEB_FORMS_PORT:-3221}
22+
ports:
23+
- "${XLSFORM_ONLINE_PORT:-8558}:8000"

packages/web-forms/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ Individual test environments, and their corresponding watch modes, also have sep
3939

4040
Upload XLSForm and XForm functionality in [`demo`](./src/demo/) app and in dev mode depends on [XLSForm-online](https://github.com/getodk/xlsform-online). Run the xlsform-online locally. By default it runs on port 8000, if you are running it on another port then you should update the [`config`](./src/demo/config.json) file.
4141

42+
### Running via containers
43+
44+
In some cases, it may be simpler to run the web-forms preview via containers.
45+
46+
See https://github.com/getodk/web-forms/tree/main/contrib/containers for details.
47+
4248
### Material Design
4349

4450
This package uses the Material Design system for the UI, though not strictly. The idea is to closely match the design to that of [ODK Collect](https://docs.getodk.org/collect-intro/).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"xlsform-online-url": "http://localhost:8000"
2+
"xlsform-online-url": "http://localhost:8558"
33
}

packages/web-forms/vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ export default defineConfig(({ mode }) => {
114114
'/fonts': resolve('./src/assets/fonts'),
115115
},
116116
},
117+
server: {
118+
host: true,
119+
port: 3221,
120+
},
117121
build: {
118122
target: 'esnext',
119123
/**

0 commit comments

Comments
 (0)