mirror of
https://github.com/thegeneralist01/config.git
synced 2026-03-07 10:59:55 +01:00
fix calorie-tracker service prestart and build flow
Run prestart from the state directory, normalize write permissions after rsync, install required dev dependencies for Astro build checks, and force clean dist rebuilds to prevent stale artifact module errors.
This commit is contained in:
parent
16ce3aebd9
commit
37979340d9
2 changed files with 12 additions and 10 deletions
8
flake.lock
generated
8
flake.lock
generated
|
|
@ -50,11 +50,11 @@
|
|||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1771307893,
|
||||
"narHash": "sha256-wHBIQSFjo/KWcY9Xvq30wsVAaNGEgirwebFQjqujPiU=",
|
||||
"lastModified": 1771309191,
|
||||
"narHash": "sha256-Y83E1JrimzUPQ1a7FpOd9dIQFJFucbV4lYPI7ik3Piw=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "977eeccd7f2702ae85ff562b4f8bd39c3cbb1898",
|
||||
"revCount": 1,
|
||||
"rev": "8cf458087edb5f2ff7e3563d4bb6e489c3264d1d",
|
||||
"revCount": 2,
|
||||
"type": "git",
|
||||
"url": "file:///home/thegeneralist/calorie-tracker"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ in
|
|||
preStart = ''
|
||||
mkdir -p ${appDir}
|
||||
rsync -a --delete --exclude ".git" --exclude "node_modules" --exclude "dist" --exclude ".astro" ${sourceDir}/ ${appDir}/
|
||||
chmod -R u+rwX ${appDir}
|
||||
|
||||
cd ${appDir}
|
||||
|
||||
|
|
@ -57,16 +58,15 @@ in
|
|||
|
||||
sed -i 's#^DATABASE_URL=.*#DATABASE_URL="file:${dataDir}/dev.db"#' .env
|
||||
|
||||
if [ ! -d node_modules ] || [ ! -d node_modules/@astrojs/node ] || [ ! -d node_modules/server-destroy ]; then
|
||||
npm ci --no-fund --no-audit
|
||||
if [ ! -d node_modules ] || [ ! -d node_modules/@astrojs/node ] || [ ! -d node_modules/server-destroy ] || [ ! -d node_modules/@vite-pwa/astro ] || [ ! -d node_modules/@astrojs/check ]; then
|
||||
npm ci --include=dev --no-fund --no-audit
|
||||
fi
|
||||
|
||||
sqlite3 "${dataDir}/dev.db" < ${./schema.sql}
|
||||
|
||||
npm run prisma:generate
|
||||
if [ ! -f dist/server/entry.mjs ]; then
|
||||
npm run build
|
||||
fi
|
||||
rm -rf dist
|
||||
npm run build
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
|
|
@ -75,7 +75,9 @@ in
|
|||
Group = "users";
|
||||
StateDirectory = "calorie-tracker";
|
||||
StateDirectoryMode = "0750";
|
||||
WorkingDirectory = appDir;
|
||||
# Keep working dir on the guaranteed StateDirectory path so preStart can
|
||||
# create ${appDir} on first boot/deploy before ExecStart runs.
|
||||
WorkingDirectory = dataDir;
|
||||
ExecStart = "${pkgs.nodejs_22}/bin/node ${appDir}/dist/server/entry.mjs";
|
||||
KillMode = "mixed";
|
||||
Restart = "always";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue