vela 0.10.6 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# data
|
|
2
|
+
|
|
3
|
+
This app's state, and the only directory in the project that outlives a release.
|
|
4
|
+
|
|
5
|
+
PocketBase keeps `data.db` and `storage/` here. Anything else the app writes —
|
|
6
|
+
its own SQLite database, uploaded files — belongs here too, and nowhere else. A
|
|
7
|
+
path built from `process.cwd()` resolves inside the release directory once the
|
|
8
|
+
app is on a server, which is where the next deploy leaves it behind and the
|
|
9
|
+
pruner eventually deletes it.
|
|
10
|
+
|
|
11
|
+
Ask for the directory rather than working it out:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { dataPath } from '@velastack/kit/server';
|
|
15
|
+
|
|
16
|
+
const db = new Database(dataPath('app.sqlite'));
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`vela` sets `VELA_DATA_DIR` in every context — `vela dev`, `vela build`, and the
|
|
20
|
+
environment it writes on each deploy — so that one call answers `<project>/data`
|
|
21
|
+
here and `/var/lib/vela/apps/<id>/shared/pb_data` on a server.
|
|
22
|
+
|
|
23
|
+
Because it is PocketBase's own directory, `vela backup` captures everything in
|
|
24
|
+
it and `vela restore` replaces it. `backups/` is the exception: PocketBase
|
|
25
|
+
leaves that out of the archives it writes.
|
|
@@ -99,6 +99,23 @@ fi
|
|
|
99
99
|
# Nothing here reads or rewrites that file.
|
|
100
100
|
[ -f "$ETC/env" ] || { : > "$ETC/env"; chmod 0600 "$ETC/env"; chown root:root "$ETC/env"; }
|
|
101
101
|
|
|
102
|
+
# Where this app keeps state that has to outlive a release.
|
|
103
|
+
#
|
|
104
|
+
# An app that works this out from its own working directory puts it inside the
|
|
105
|
+
# release, which is the one place it cannot survive: `current` moves on the next
|
|
106
|
+
# deploy and the pruner deletes what it left behind. An instance with a database
|
|
107
|
+
# shares PocketBase's directory, so anything the app writes there is inside the
|
|
108
|
+
# archives `vela backup` takes and inside the directory `vela restore` swaps. An
|
|
109
|
+
# instance without one gets a directory of its own, which nothing backs up -
|
|
110
|
+
# there is no database to back it up alongside.
|
|
111
|
+
if [ "$BACKEND" = "1" ]; then
|
|
112
|
+
APP_DATA_DIR="$APP/shared/pb_data"
|
|
113
|
+
else
|
|
114
|
+
APP_DATA_DIR="$APP/shared/data"
|
|
115
|
+
mkdir -p "$APP_DATA_DIR"
|
|
116
|
+
chown "$VELA_USER:$VELA_USER" "$APP_DATA_DIR"
|
|
117
|
+
fi
|
|
118
|
+
|
|
102
119
|
runtime_tmp=$(mktemp "$ETC/.runtime.XXXXXX")
|
|
103
120
|
{
|
|
104
121
|
printf '# Generated by vela on each deploy. Edit /etc/vela/apps/%s/env instead.\n' "$INSTANCE"
|
|
@@ -108,6 +125,7 @@ runtime_tmp=$(mktemp "$ETC/.runtime.XXXXXX")
|
|
|
108
125
|
printf 'ORIGIN=%s\n' "$ORIGIN"
|
|
109
126
|
printf 'PB_PORT=%s\n' "$PB_PORT"
|
|
110
127
|
printf 'POCKETBASE_URL=http://127.0.0.1:%s\n' "$PB_PORT"
|
|
128
|
+
printf 'VELA_DATA_DIR=%s\n' "$APP_DATA_DIR"
|
|
111
129
|
printf 'VELA_APP_ID=%s\n' "$APP_ID"
|
|
112
130
|
printf 'VELA_APP_NAME=%s\n' "$APP_NAME"
|
|
113
131
|
printf 'VELA_ENV=%s\n' "$ENV_TAG"
|