Compare commits

...

2 Commits

Author SHA1 Message Date
58f5af27db Fixes for all the bullshit
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful
2026-02-07 16:38:39 -03:00
89cb014163 Trash 2026-02-07 15:56:30 -03:00
5 changed files with 20 additions and 77 deletions

View File

@@ -148,7 +148,7 @@ services:
- CMD
- node
- -e
- 'require("http").get("http://127.0.0.1:3000/", (r) => { r.resume(); process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1); }).on("error", () => process.exit(1))'
- 'require("http").get("http://0.0.0.0:3000/", {timeout: 5000}, (r) => { r.resume(); process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1); }).on("error", () => process.exit(1))'
interval: 30s
timeout: 10s
retries: 3

View File

@@ -128,10 +128,10 @@ services:
QR_API_URL: http://qr_api:8080
healthcheck:
test:
[
'CMD-SHELL',
'node -e "require(''http'').get(''http://127.0.0.1:3000/'', (r) => { r.resume(); process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1); }).on(''error'', () => process.exit(1))"',
]
- CMD
- node
- -e
- 'require("http").get("http://0.0.0.0:3000/", {timeout: 5000}, (r) => { r.resume(); process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1); }).on("error", () => process.exit(1))'
interval: 30s
timeout: 10s
retries: 3

View File

@@ -1,57 +0,0 @@
# Resetting the Kutt PostgreSQL password
If you lost the stack env vars (e.g. after deleting the Portainer stack) and need to use the existing database with a new password, you have two options.
**Default DB user/db name from compose:** `kutt` / `kutt` (or whatever you set in `DB_USER` / `DB_NAME`).
**Data path on host:** `/mnt/config/docker/kutt/postgres` (from `docker-compose.portainer.yml`).
---
## Option A: Fresh start (delete all Kutt data)
Use this if you **dont need** existing links/users.
1. On the host, remove the Postgres data directory:
```bash
sudo rm -rf /mnt/config/docker/kutt/postgres
```
2. In Portainer, (re-)create the stack and set env vars, including a new `DB_PASSWORD`.
3. Deploy. Postgres will initialise a new database with the new password.
---
## Option B: Keep data, force-set a new password
Use this if you **want to keep** existing Kutt data but dont know the current password.
**Stop the stack first** (so nothing is using the Postgres data volume).
1. On the host, temporarily allow local connections without a password:
```bash
cd /mnt/config/docker/kutt/postgres
cp pg_hba.conf pg_hba.conf.bak
echo 'local all all trust' > pg_hba.conf
echo 'host all all 127.0.0.1/32 trust' >> pg_hba.conf
echo 'host all all ::1/128 trust' >> pg_hba.conf
```
2. Start a temporary Postgres container (it will use the modified `pg_hba.conf`):
```bash
docker run -d --name pg-reset \
-v /mnt/config/docker/kutt/postgres:/var/lib/postgresql/data \
postgres:16-alpine
sleep 5
```
3. Set the new password (replace `kutt` if you use a different `DB_USER`, and set `YOUR_NEW_PASSWORD`):
```bash
docker exec pg-reset psql -U postgres -c "ALTER USER kutt PASSWORD 'YOUR_NEW_PASSWORD';"
```
4. Stop the temporary container and restore `pg_hba.conf`:
```bash
docker stop pg-reset && docker rm pg-reset
cd /mnt/config/docker/kutt/postgres
mv pg_hba.conf.bak pg_hba.conf
```
5. In Portainer, create/redeploy the stack and set `DB_PASSWORD` (and other env vars) to the same `YOUR_NEW_PASSWORD`.

2
qr-api/.npmrc Normal file
View File

@@ -0,0 +1,2 @@
# Force pnpm to run build scripts for better-sqlite3
enable-pre-post-scripts=true

View File

@@ -1,25 +1,23 @@
# Build stage: TypeScript only (no native deps in this stage).
# Build stage: use npm (not pnpm) to avoid workspace issues with better-sqlite3.
FROM node:20-bookworm-slim AS builder
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install
COPY package.json ./
RUN npm install
# Verify better-sqlite3 was compiled; fail build if not.
RUN test -f node_modules/better-sqlite3/build/Release/better_sqlite3.node || \
(echo "ERROR: better-sqlite3.node not found after npm install" && exit 1)
COPY . .
RUN pnpm run build
RUN npm run build
RUN npm prune --production
# Runtime: install deps here so better-sqlite3 is compiled for this exact image/platform.
# Runtime: copy pre-built node_modules from builder.
FROM node:20-bookworm-slim
WORKDIR /app
ENV NODE_ENV=production
# Install build deps needed to compile better-sqlite3; remove after install to keep image small.
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
RUN corepack enable && corepack prepare pnpm@latest --activate
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install --prod \
&& apt-get purge -y python3 make g++ \
&& apt-get autoremove -y --purge \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json
EXPOSE 8080
CMD ["node", "dist/index.js"]