Compare commits
46 Commits
52e45a663e
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ebeb4574ad | |||
| 7fce46bff2 | |||
| 9380273cba | |||
| d398226723 | |||
| e225f2ec2c | |||
| 85bbe7b61f | |||
| de1de1d3bc | |||
| ef8a7858b2 | |||
| 11615ee4cb | |||
| dc5089c011 | |||
| aaa04e1d26 | |||
| 0e22acc077 | |||
| 386dd2d6a2 | |||
| 85e6304bae | |||
| cf6b5785d7 | |||
| cf2f3d0255 | |||
| 66db3de33d | |||
| bfcb7d7fd3 | |||
| a0451a2084 | |||
| d003d3c1c7 | |||
| d91ff3f07c | |||
| 786dc4c825 | |||
| d5a6d0bfd7 | |||
| ef8c4bafe6 | |||
| 97082b0233 | |||
| 93b6c0b17d | |||
| f038f37001 | |||
| e5e976caff | |||
| e5b6ce3bdc | |||
| 5fb1c5d0b0 | |||
| f6218283f1 | |||
| 58311ba2df | |||
| 3ff5e6b031 | |||
| 1916bc33e4 | |||
| 410f72caf0 | |||
| 9847b4c5cc | |||
| f0e2c60620 | |||
| fc53062eb1 | |||
| ae0502ce16 | |||
| 28366151cf | |||
| 3378d5c523 | |||
| c8674dd56f | |||
| b7c4df42e0 | |||
| 3a523aafde | |||
| a8ef158fd7 | |||
| 9ca98d96db |
+23
-9
@@ -1,7 +1,9 @@
|
|||||||
# Stage 1: Dependencies
|
# 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
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -10,41 +12,53 @@ COPY package.json package-lock.json* ./
|
|||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
# Stage 2: Build
|
# Stage 2: Build
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-slim AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
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 --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
ENV DATABASE_URL="file:./dev.db"
|
||||||
|
|
||||||
RUN npx prisma generate
|
RUN npx prisma generate
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 3: Production
|
# Stage 3: Production
|
||||||
FROM node:20-alpine AS runner
|
FROM node:20-slim AS runner
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
RUN adduser --system --uid 1001 nextjs
|
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/public ./public
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
COPY --from=builder /app/prisma ./prisma
|
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/node_modules/@prisma ./node_modules/@prisma
|
||||||
|
|
||||||
COPY --from=builder /app/prisma/schema.prisma /app/schema.prisma
|
COPY --from=builder /app/prisma/schema.prisma /app/schema.prisma
|
||||||
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
USER nextjs
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
ENV HOSTNAME="0.0.0.0"
|
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"]
|
CMD ["node", "server.js"]
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
-3
@@ -85,13 +85,13 @@ services:
|
|||||||
- "traefik.http.routers.${NAME_SERVICE}.rule=Host(`recall.vodorod.cl`)"
|
- "traefik.http.routers.${NAME_SERVICE}.rule=Host(`recall.vodorod.cl`)"
|
||||||
environment:
|
environment:
|
||||||
- TZ=America/Santiago
|
- TZ=America/Santiago
|
||||||
- DATABASE_URL=file:./data/dev.db
|
- DATABASE_URL=file:/app/data/dev.db
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
networks:
|
networks:
|
||||||
- homelab-net
|
- homelab-net
|
||||||
mem_limit: 32m
|
mem_limit: 512m
|
||||||
mem_reservation: 16m
|
mem_reservation: 256m
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
homelab-net:
|
homelab-net:
|
||||||
|
|||||||
@@ -248,3 +248,7 @@ src/
|
|||||||
└── types/
|
└── types/
|
||||||
└── note.ts
|
└── note.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
nueva prueba
|
||||||
BIN
Binary file not shown.
+1
-1
@@ -8,5 +8,5 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=file:./data/dev.db
|
- DATABASE_URL=file:/app/data/dev.db
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
@@ -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 "$@"
|
||||||
@@ -105,21 +105,22 @@ export async function POST(req: NextRequest) {
|
|||||||
|
|
||||||
const createdAt = parseDate((item as { createdAt?: string }).createdAt)
|
const createdAt = parseDate((item as { createdAt?: string }).createdAt)
|
||||||
const updatedAt = parseDate((item as { updatedAt?: string }).updatedAt)
|
const updatedAt = parseDate((item as { updatedAt?: string }).updatedAt)
|
||||||
|
const itemWithId = item as { id?: string }
|
||||||
|
|
||||||
if (item.id) {
|
if (itemWithId.id) {
|
||||||
const existing = await tx.note.findUnique({ where: { id: item.id } })
|
const existing = await tx.note.findUnique({ where: { id: itemWithId.id } })
|
||||||
if (existing) {
|
if (existing) {
|
||||||
await tx.note.update({
|
await tx.note.update({
|
||||||
where: { id: item.id },
|
where: { id: itemWithId.id },
|
||||||
data: { ...noteData, createdAt, updatedAt },
|
data: { ...noteData, createdAt, updatedAt },
|
||||||
})
|
})
|
||||||
await tx.noteTag.deleteMany({ where: { noteId: item.id } })
|
await tx.noteTag.deleteMany({ where: { noteId: itemWithId.id } })
|
||||||
processed++
|
processed++
|
||||||
} else {
|
} else {
|
||||||
await tx.note.create({
|
await tx.note.create({
|
||||||
data: {
|
data: {
|
||||||
...noteData,
|
...noteData,
|
||||||
id: item.id,
|
id: itemWithId.id,
|
||||||
createdAt,
|
createdAt,
|
||||||
updatedAt,
|
updatedAt,
|
||||||
creationSource: 'import',
|
creationSource: 'import',
|
||||||
@@ -150,8 +151,8 @@ export async function POST(req: NextRequest) {
|
|||||||
processed++
|
processed++
|
||||||
}
|
}
|
||||||
|
|
||||||
const noteId = item.id
|
const noteId = itemWithId.id
|
||||||
? (await tx.note.findUnique({ where: { id: item.id } }))?.id
|
? (await tx.note.findUnique({ where: { id: itemWithId.id } }))?.id
|
||||||
: (await tx.note.findFirst({ where: { title: item.title } }))?.id
|
: (await tx.note.findFirst({ where: { title: item.title } }))?.id
|
||||||
|
|
||||||
if (noteId && tags.length > 0) {
|
if (noteId && tags.length > 0) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export async function PUT(req: NextRequest, { params }: { params: Promise<{ id:
|
|||||||
throw new ValidationError(result.error.issues)
|
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 } })
|
const existingNote = await prisma.note.findUnique({ where: { id } })
|
||||||
if (!existingNote) {
|
if (!existingNote) {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Dashboard } from '@/components/dashboard'
|
import { Dashboard } from '@/components/dashboard'
|
||||||
import { getDashboardData } from '@/lib/dashboard'
|
import { getDashboardData } from '@/lib/dashboard'
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
export default async function HomePage() {
|
export default async function HomePage() {
|
||||||
const data = await getDashboardData(6)
|
const data = await getDashboardData(6)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user