Skip to content

Commit d9855d1

Browse files
committed
Updated quickstart doc
1 parent 0ca8208 commit d9855d1

File tree

3 files changed

+89
-42
lines changed

3 files changed

+89
-42
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
Note: with this release all the environment variables will be read from the environment, when the service is started, not during build time. Remember to load in your environment all the variables that you need when you start the service in production. This will not affect development setup.
66

7+
* Updated quickstart documenting the changes related to environment variables (\#492).
8+
* Fixed bug in default dataset selection when job references a deleted dataset (\#492).
79
* Fixed v1 workflow task version update bug (\#492).
810
* Added `npm pack` artifacts to files published by the CI during the release (\#492).
911
* Fixed v2 admin job download link (\#492).

docs/quickstart.md

Lines changed: 86 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Quickstart instructions
22

3-
## Intall node
3+
## Install node
44

55
Versions 18 or 20 of Node.js are recommended (check your version with `node
66
-v`). Version 16 is known to work, but not recommended.
@@ -16,6 +16,22 @@ nvm alias default 18
1616

1717
## Install fractal-web
1818

19+
There are 2 ways to install fractal-web: from release packages (more suited for production and testing) and from git repository (more suited for development).
20+
21+
### Install fractal-web from release packages
22+
23+
Starting from version 1.1.0, fractal-web releases provide tar.gz files containing the built files for each supported node version. You can install these packages with the following command:
24+
25+
```
26+
FRACTAL_WEB_VERSION=1.1.0 && NODE_MAJOR_VERSION=20 && wget -qO- "https://github.com/fractal-analytics-platform/fractal-web/releases/download/v${FRACTAL_WEB_VERSION}/node-${NODE_MAJOR_VERSION}-fractal-web-v${FRACTAL_WEB_VERSION}.tar.gz" | tar -xz
27+
```
28+
29+
**Note**: this will unpack in the current working directory the file `package.json` and the folders `build` and `node_modules`.
30+
31+
To start the application installed in this way see the section "Run fractal-web from the build folder".
32+
33+
### Install fractal-web from git repository
34+
1935
Clone this repository
2036
```bash
2137
git clone https://github.com/fractal-analytics-platform/fractal-web.git
@@ -32,59 +48,27 @@ npm install
3248

3349
## Set environment variables
3450

35-
Environment variables are set either in `.env` or `.env.development` files, see
36-
[vite documentation](https://vitejs.dev/guide/env-and-mode.html#env-files)
37-
(briefly: `.env.development` is the relevant file when using `npm run dev`).
51+
To properly run fractal-web you have to configure some environment variables. The [environment variables page](./environment-variables.md) contains the complete list of supported environment variables and their default values.
3852

39-
Here is an example of a `.env` file:
40-
```bash
41-
FRACTAL_SERVER_HOST=http://localhost:8000
53+
If you want to run the application executing `node` in the `build` folder you have to export the environment variables in your shell. See the section "Run fractal-web from the build folder" for more details.
4254

43-
# AUTH COOKIE
44-
AUTH_COOKIE_NAME=fastapiusersauth
45-
AUTH_COOKIE_SECURE=false
46-
# remember to set this in production
47-
AUTH_COOKIE_DOMAIN=
48-
AUTH_COOKIE_PATH=/
49-
AUTH_COOKIE_MAX_AGE=1800
50-
AUTH_COOKIE_SAME_SITE=lax
51-
AUTH_COOKIE_HTTP_ONLY=true
52-
53-
# PUBLIC VARIABLES (accessible from client side)
54-
PUBLIC_FRACTAL_ADMIN_SUPPORT_EMAIL=help@localhost
55-
PUBLIC_UPDATE_JOBS_INTERVAL=3000
56-
PUBLIC_OAUTH_CLIENT_NAME=
57-
58-
# Logging configuration (used in Svelte backend)
59-
LOG_FILE=/tmp/fractal-web.log
60-
LOG_LEVEL_FILE=info
61-
LOG_LEVEL_CONSOLE=warn
62-
```
55+
When running the application from the git repository, environment variables are set either in `.env` or `.env.development` files, see
56+
[vite documentation](https://vitejs.dev/guide/env-and-mode.html#env-files)
57+
(briefly: `.env.development` is the relevant file when using `npm run dev` and `.env` is the relevant file when using `npm run preview`).
6358

6459
You can also add your customizations in a file named `.env.local` or `.env.development.local` to avoid writing on env files that are under version control.
6560

66-
## Web client startup
67-
68-
For testing and production, start fractal-web executing
69-
```
70-
npm run build # corresponding to `vite build`, which creates a `build` folder
71-
ORIGIN=http://localhost:5173 PORT=5173 node build
72-
```
61+
### Common issues related to environment variables
7362

74-
The application is now running at `http://localhost:5173`.
63+
The `node` command relies on some extra environment variables, and especially on `ORIGIN`:
7564

76-
Note that the `node` command relies on some environment variables, and
77-
especially on `ORIGIN`:
7865
> HTTP doesn't give SvelteKit a reliable way to know the URL that is currently
7966
> being requested. The simplest way to tell SvelteKit where the app is being
8067
> served is to set the `ORIGIN` environment variable
8168
> (see [SvelteKit node servers documentation](https://kit.svelte.dev/docs/adapter-node#environment-variables-origin-protocolheader-hostheader-and-port-header)).
8269
> A wrong origin value will result in the error message "Cross-site POST form submissions are forbidden".
8370
84-
For development, run the client application via
85-
```bash
86-
npm run dev
87-
```
71+
Unexpected behaviors can be related to wrong values of the `AUTH_COOKIE_DOMAIN` variable:
8872

8973
> A typical gotcha: if there is a mismatch between the cookie domain and the
9074
> URL you are using (e.g. one points to localhost and the other one to
@@ -94,3 +78,64 @@ npm run dev
9478
> inferred from the HTTP call. This is useful to avoid domain mismatch issues
9579
> during testing and development, but in production is suggested to set it as
9680
> the name of the domain where the fractal-web server is running.
81+
82+
## Run fractal-web from the build folder
83+
84+
You can create a script with the following content to run fractal-web installed from a release package:
85+
86+
```commandline
87+
#!/bin/sh
88+
89+
export FRACTAL_SERVER_HOST=http://localhost:8000
90+
export PUBLIC_FRACTAL_ADMIN_SUPPORT_EMAIL=help@localhost
91+
export PUBLIC_OAUTH_CLIENT_NAME=
92+
# remember to set this in production
93+
export AUTH_COOKIE_DOMAIN=
94+
# set this to true in production
95+
export AUTH_COOKIE_SECURE=false
96+
97+
export ORIGIN=http://localhost:5173
98+
export PORT=5173
99+
100+
export LOG_FILE=fractal-web.log
101+
export LOG_LEVEL_FILE=info
102+
export LOG_LEVEL_CONSOLE=warn
103+
104+
# default values are usually fine for the following variables; remove comments if needed
105+
#export AUTH_COOKIE_NAME=fastapiusersauth
106+
#export AUTH_COOKIE_PATH=/
107+
#export AUTH_COOKIE_SAME_SITE=lax
108+
#export PUBLIC_UPDATE_JOBS_INTERVAL=3000
109+
110+
node build/
111+
```
112+
113+
**Note**: starting from Node 20 you can also load the environment variables from a file using the `--env-file` flag:
114+
115+
```commandline
116+
node --env-file=.env build
117+
```
118+
119+
## Run fractal-web from git repo
120+
121+
For development, run the client application via
122+
123+
```bash
124+
npm run dev
125+
```
126+
127+
The application will run at `http://localhost:5173`.
128+
129+
To test a production build, first execute
130+
131+
```bash
132+
npm run build
133+
```
134+
135+
And then
136+
137+
```bash
138+
npm run preview
139+
```
140+
141+
Also in this case the application runs at `http://localhost:5173`.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"dev": "vite dev",
77
"build": "vite build",
8-
"preview": "vite preview",
8+
"preview": "vite preview --port 5173",
99
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
1010
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
1111
"lint": "prettier --check . && eslint .",

0 commit comments

Comments
 (0)