Compare commits
19 Commits
dockerise
...
70bd76f49e
| Author | SHA1 | Date | |
|---|---|---|---|
| 70bd76f49e | |||
| c428aae077 | |||
| 89d2aaca75 | |||
| 4413374429 | |||
| 2a953ef5ce | |||
| 0b038f4dea | |||
| 1d6e5b5d4c | |||
| c5d689a9a8 | |||
| f557360105 | |||
| caf6eabe32 | |||
| 1eb42c7a18 | |||
| 865846c6be | |||
| e978d0df97 | |||
| 31bfbffb4d | |||
| a0d63fc10e | |||
| 09585d8954 | |||
| 74023040fc | |||
| a61b342c4c | |||
| b99e636e74 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,7 +17,6 @@ Thumbs.db
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
pgdata
|
||||
|
||||
# Vite
|
||||
vite.config.js.timestamp-*
|
||||
|
||||
54
Dockerfile
54
Dockerfile
@@ -1,54 +0,0 @@
|
||||
# Build stage
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
|
||||
# Install pnpm
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# Install all dependencies (including dev)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN pnpm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files from builder
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
|
||||
# Install pnpm
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# Install all dependencies (including dev for drizzle-kit)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy built application from builder
|
||||
COPY --from=builder /app/build ./build
|
||||
|
||||
# Copy drizzle config and schema for migrations
|
||||
COPY drizzle.config.ts ./
|
||||
COPY tsconfig.json ./
|
||||
COPY src/lib/server/db ./src/lib/server/db
|
||||
|
||||
# Install netcat for database readiness check
|
||||
RUN apk add --no-cache netcat-openbsd
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY entrypoint.sh /app/entrypoint.sh
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
|
||||
# Expose port (SvelteKit Node adapter default)
|
||||
EXPOSE 5173
|
||||
|
||||
# Start the application
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
20
compose.yaml
20
compose.yaml
@@ -9,22 +9,4 @@ services:
|
||||
POSTGRES_PASSWORD: mysecretpassword
|
||||
POSTGRES_DB: memento
|
||||
volumes:
|
||||
# - ~/tmp/pgdata:/var/lib/postgresql
|
||||
- ./pgdata:/var/lib/postgresql
|
||||
|
||||
app:
|
||||
build: .
|
||||
restart: always
|
||||
ports:
|
||||
- 5173:3000
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
DATABASE_URL: postgresql://root:mysecretpassword@db:5432/memento
|
||||
UPLOAD_DIR: /app/uploads
|
||||
volumes:
|
||||
# - .:/app
|
||||
- ./uploads:/app/uploads
|
||||
# - /app/node_modules
|
||||
|
||||
|
||||
- ~/tmp/pgdata:/var/lib/postgresql
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Wait for PostgreSQL to be ready
|
||||
while ! nc -z db 5432; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Run database migrations
|
||||
echo "Pushing database schema..."
|
||||
pnpm run db:push
|
||||
|
||||
# Start the application
|
||||
echo "Starting application..."
|
||||
node build
|
||||
@@ -213,7 +213,7 @@
|
||||
<img
|
||||
src={entry.image}
|
||||
alt="Entry"
|
||||
class="w-full h-auto max-h-128 object-cover"
|
||||
class="w-full h-auto max-h-96 object-cover"
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
@@ -256,7 +256,7 @@
|
||||
<img
|
||||
src={previewImage}
|
||||
alt="Preview"
|
||||
class="w-full h-auto max-h-128 object-cover"
|
||||
class="w-full h-auto max-h-96 object-cover"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -57,11 +57,17 @@ export async function updateEntry(entry) {
|
||||
}
|
||||
|
||||
export async function deleteEntry(entry) {
|
||||
await fetch(`/api/entry/delete`, {
|
||||
const res = await fetch(`/api/entry/delete`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: entry.id })
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
entry = null;
|
||||
} else {
|
||||
alert('Failed to delete entry');
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,10 @@
|
||||
let { children, data } = $props();
|
||||
let dateValue = $derived(data.date);
|
||||
let entries = $derived(data.entries);
|
||||
let title = $state("Memento")
|
||||
|
||||
$effect(() => {
|
||||
// Navigate when dateValue changes
|
||||
goto(`/${dateValue}`);
|
||||
title = `Memento: ${dateValue}`
|
||||
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
@@ -31,10 +28,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{title}</title>
|
||||
<link rel="icon" href={favicon} />
|
||||
</svelte:head>
|
||||
<svelte:head><link rel="icon" href={favicon} /></svelte:head>
|
||||
<ModeWatcher />
|
||||
|
||||
<div
|
||||
|
||||
@@ -61,7 +61,7 @@ async function getEntryByMonth(monthString: string) {
|
||||
const endDate = new Date(year, month, 1, 0, 0, 0, 0)
|
||||
|
||||
const entries = await db.select().from(entryTable).where(
|
||||
sql`${entryTable.date} >= ${startDate.toISOString()}::timestamp AND ${entryTable.date} < ${endDate.toISOString()}::timestamp ORDER BY ${entryTable.date} DESC`
|
||||
sql`${entryTable.date} >= ${startDate.toISOString()}::timestamp AND ${entryTable.date} < ${endDate.toISOString()}::timestamp`
|
||||
)
|
||||
|
||||
return httpResponse(entries, 200)
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import adapter from '@sveltejs/adapter-node';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
kit: {
|
||||
adapter: adapter(),
|
||||
csrf: {
|
||||
checkOrigin: false
|
||||
}
|
||||
}
|
||||
};
|
||||
const config = { kit: { adapter: adapter() } };
|
||||
|
||||
export default config;
|
||||
|
||||
Reference in New Issue
Block a user