Compare commits

...

29 Commits

Author SHA1 Message Date
darroyo 7fce46bff2 d 2026-03-27 10:55:43 -03:00
darroyo d398226723 j 2026-03-27 10:09:44 -03:00
darroyo 85bbe7b61f fix: Increase memory limit to 512MB for Prisma db push 2026-03-24 23:07:10 -03:00
darroyo de1de1d3bc fix: Run prisma db push but continue if OOM and DB exists 2026-03-24 23:04:26 -03:00
darroyo ef8a7858b2 fix: Only run prisma db push if database doesn't exist to avoid OOM 2026-03-24 23:02:14 -03:00
darroyo dc5089c011 fix: Make entrypoint more robust to handle volume permission issues 2026-03-24 15:19:21 -03:00
darroyo 0e22acc077 prueba 2026-03-24 15:08:30 -03:00
darroyo 85e6304bae fix: Use absolute path for DATABASE_URL to avoid working directory issues 2026-03-24 14:46:15 -03:00
darroyo cf6b5785d7 fix: Change to /app directory before running prisma and node 2026-03-24 13:13:09 -03:00
darroyo 66db3de33d fix: Run container as root to avoid volume permission issues 2026-03-24 12:59:09 -03:00
darroyo a0451a2084 fix: Add --skip-generate to avoid memory issues in Prisma 5 2026-03-24 12:39:20 -03:00
darroyo d91ff3f07c fix: Run prisma db push as root, then switch to nextjs user for app 2026-03-24 12:06:58 -03:00
darroyo d5a6d0bfd7 fix: Ensure data directory exists and has proper permissions before prisma db push 2026-03-24 11:44:39 -03:00
darroyo 97082b0233 fix: Copy @prisma modules needed for prisma CLI 2026-03-24 10:21:05 -03:00
darroyo 93b6c0b17d fix: Simplify entrypoint - remove npm cache directories 2026-03-24 10:03:51 -03:00
darroyo f038f37001 fix: Use local Prisma 5 from node_modules instead of downloading Prisma 7 2026-03-24 09:33:31 -03:00
darroyo e5e976caff fix: Remove --skip-generate flag not supported in Prisma 7 2026-03-24 09:14:59 -03:00
darroyo e5b6ce3bdc fix: Use npx with proper HOME and cache directories for prisma 2026-03-24 09:08:24 -03:00
darroyo 5fb1c5d0b0 fix: Copy .bin folder and use local prisma in entrypoint 2026-03-24 09:04:26 -03:00
darroyo f6218283f1 fix: Create home directory for nextjs user to fix npm permissions 2026-03-24 09:02:54 -03:00
darroyo 3ff5e6b031 fix: Improve entrypoint script with better database initialization 2026-03-23 23:54:32 -03:00
darroyo 1916bc33e4 fix: Add entrypoint script to initialize database on container start 2026-03-23 23:53:18 -03:00
darroyo 9847b4c5cc fix: Force dynamic rendering on home page to avoid Prisma build error 2026-03-23 23:47:28 -03:00
darroyo fc53062eb1 fix: Add DATABASE_URL env var in builder stage for Prisma 2026-03-23 23:32:19 -03:00
darroyo 28366151cf fix: Remove libc6-compat (Alpine package) from Debian-based Dockerfile 2026-03-23 23:17:27 -03:00
darroyo c8674dd56f fix: Change Alpine to Debian-based image for Prisma compatibility
Alpine Linux doesn't have libssl1.1 which Prisma needs.
Using node:20-slim instead with proper OpenSSL libraries.
2026-03-23 23:13:45 -03:00
darroyo 3a523aafde fix: Exclude id field from noteData in update route 2026-03-23 23:08:17 -03:00
darroyo 9ca98d96db fix: TypeScript error in import route - cast item to access id 2026-03-23 23:05:03 -03:00
darroyo bd1a5bc21c j 2026-03-23 22:49:06 -03:00
9 changed files with 68 additions and 23 deletions
+23 -9
View File
@@ -1,7 +1,9 @@
# Stage 1: Dependencies
FROM node:20-alpine AS deps
FROM node:20-slim AS deps
RUN apk add --no-cache libc6-compat
RUN apt-get update && apt-get install -y --no-install-recommends \
openssl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
@@ -10,41 +12,53 @@ COPY package.json package-lock.json* ./
RUN npm ci
# Stage 2: Build
FROM node:20-alpine AS builder
FROM node:20-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
openssl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV DATABASE_URL="file:./dev.db"
RUN npx prisma generate
RUN npm run build
# Stage 3: Production
FROM node:20-alpine AS runner
FROM node:20-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
RUN apt-get update && apt-get install -y --no-install-recommends \
openssl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=builder /app/prisma/schema.prisma /app/schema.prisma
USER nextjs
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
ENV DATABASE_URL="file:./dev.db"
ENV DATABASE_URL="file:/app/data/dev.db"
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["node", "server.js"]
Vendored
+4 -5
View File
@@ -44,8 +44,7 @@ pipeline {
cat .dockerignore || echo ".dockerignore no encontrado"
docker -v
docker build \
-t ${URL_REGISTRY}/${PROJECT}/${NAME_SERVICE}:${BUILD_NUMBER} \
-f .
-t ${URL_REGISTRY}/${PROJECT}/${NAME_SERVICE}:${BUILD_NUMBER} .
docker tag ${URL_REGISTRY}/${PROJECT}/${NAME_SERVICE}:${BUILD_NUMBER} \
${URL_REGISTRY}/${PROJECT}/${NAME_SERVICE}:latest
"""
@@ -86,13 +85,13 @@ services:
- "traefik.http.routers.${NAME_SERVICE}.rule=Host(`recall.vodorod.cl`)"
environment:
- TZ=America/Santiago
- DATABASE_URL=file:./data/dev.db
- DATABASE_URL=file:/app/data/dev.db
volumes:
- ./data:/app/data
networks:
- homelab-net
mem_limit: 32m
mem_reservation: 16m
mem_limit: 512m
mem_reservation: 256m
restart: unless-stopped
networks:
homelab-net:
+4
View File
@@ -248,3 +248,7 @@ src/
└── types/
└── note.ts
```
nueva prueba
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -8,5 +8,5 @@ services:
volumes:
- ./data:/app/data
environment:
- DATABASE_URL=file:./data/dev.db
- DATABASE_URL=file:/app/data/dev.db
restart: unless-stopped
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
set -e
cd /app
echo "Checking database..."
# Ensure data directory exists with proper permissions
mkdir -p /app/data
chmod 777 /app/data
# Run db push (creates/updates database schema)
# If it fails due to OOM but DB exists, continue anyway
./node_modules/prisma/build/index.js db push --skip-generate || {
exit_code=$?
if [ -f /app/data/dev.db ]; then
echo "db push failed (code $exit_code) but database exists, continuing..."
else
echo "db push failed and database does not exist"
exit $exit_code
fi
}
echo "Starting application..."
exec "$@"
+8 -7
View File
@@ -105,21 +105,22 @@ export async function POST(req: NextRequest) {
const createdAt = parseDate((item as { createdAt?: string }).createdAt)
const updatedAt = parseDate((item as { updatedAt?: string }).updatedAt)
const itemWithId = item as { id?: string }
if (item.id) {
const existing = await tx.note.findUnique({ where: { id: item.id } })
if (itemWithId.id) {
const existing = await tx.note.findUnique({ where: { id: itemWithId.id } })
if (existing) {
await tx.note.update({
where: { id: item.id },
where: { id: itemWithId.id },
data: { ...noteData, createdAt, updatedAt },
})
await tx.noteTag.deleteMany({ where: { noteId: item.id } })
await tx.noteTag.deleteMany({ where: { noteId: itemWithId.id } })
processed++
} else {
await tx.note.create({
data: {
...noteData,
id: item.id,
id: itemWithId.id,
createdAt,
updatedAt,
creationSource: 'import',
@@ -150,8 +151,8 @@ export async function POST(req: NextRequest) {
processed++
}
const noteId = item.id
? (await tx.note.findUnique({ where: { id: item.id } }))?.id
const noteId = itemWithId.id
? (await tx.note.findUnique({ where: { id: itemWithId.id } }))?.id
: (await tx.note.findFirst({ where: { title: item.title } }))?.id
if (noteId && tags.length > 0) {
+1 -1
View File
@@ -33,7 +33,7 @@ export async function PUT(req: NextRequest, { params }: { params: Promise<{ id:
throw new ValidationError(result.error.issues)
}
const { tags, ...noteData } = result.data
const { tags, id: _, ...noteData } = result.data
const existingNote = await prisma.note.findUnique({ where: { id } })
if (!existingNote) {
+2
View File
@@ -1,6 +1,8 @@
import { Dashboard } from '@/components/dashboard'
import { getDashboardData } from '@/lib/dashboard'
export const dynamic = 'force-dynamic'
export default async function HomePage() {
const data = await getDashboardData(6)