From 201280dc54ca02d469b952501b4e3c4351c30225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20St=C3=B8rdal?= <30749741+hakon55@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:05:08 +0200 Subject: [PATCH] Heftig rekatorering --- Dockerfile | 63 ++-- src/lib/WorkoutDisplay.svelte | 148 ---------- src/lib/WorkoutLogger.svelte | 271 ------------------ .../components}/DbConnection.svelte | 3 +- src/lib/components/ExampleNewExercise.svelte | 107 +++++++ src/lib/components/QuickAddButton.svelte | 29 ++ src/{routes => lib/components}/db.remote.js | 0 src/lib/db.ts | 8 +- src/routes/+page.svelte | 23 +- src/routes/ExerciseField.svelte | 55 ++++ src/routes/WorkoutDisplay.svelte | 120 ++++++++ src/routes/WorkoutLogger.svelte | 152 ++++++++++ src/routes/WorkoutStatCard.svelte | 37 +++ src/routes/workout.remote.ts | 118 ++++---- src/routes/workoutData.ts | 72 +++++ src/routes/workoutUtils.ts | 28 ++ 16 files changed, 700 insertions(+), 534 deletions(-) delete mode 100644 src/lib/WorkoutDisplay.svelte delete mode 100644 src/lib/WorkoutLogger.svelte rename src/{routes => lib/components}/DbConnection.svelte (72%) create mode 100644 src/lib/components/ExampleNewExercise.svelte create mode 100644 src/lib/components/QuickAddButton.svelte rename src/{routes => lib/components}/db.remote.js (100%) create mode 100644 src/routes/ExerciseField.svelte create mode 100644 src/routes/WorkoutDisplay.svelte create mode 100644 src/routes/WorkoutLogger.svelte create mode 100644 src/routes/WorkoutStatCard.svelte create mode 100644 src/routes/workoutData.ts create mode 100644 src/routes/workoutUtils.ts diff --git a/Dockerfile b/Dockerfile index 824bfe1..0fd045f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,64 +1,37 @@ -# Use the official Node.js runtime as the base image -FROM node:20-alpine AS base +# Build stage - includes dev dependencies for building the app +FROM node:22-alpine AS build -# Set the working directory inside the container +# Set working directory for build operations WORKDIR /app -# Copy package.json and package-lock.json (if available) +# Copy package files to install dependencies COPY package*.json ./ +# Install all dependencies including dev dependencies needed for build +RUN npm ci -# Install all dependencies (including devDependencies for building) -RUN npm ci && npm cache clean --force - -# Copy the rest of the application code +# Copy source code and build the application COPY . . - -# Set build-time environment variables for SvelteKit -ARG DATABASE_URL="postgresql://builduser:buildpass@localhost:5432/builddb" -ENV DATABASE_URL=${DATABASE_URL} - -# Run SvelteKit sync to generate .svelte-kit directory and prepare the build -RUN npm run prepare - -# Build the application with environment variables available RUN npm run build -# Production stage -FROM node:20-alpine AS production +# Production stage - clean runtime environment +FROM node:22-alpine AS production -# Install dumb-init for proper signal handling -RUN apk add --no-cache dumb-init - -# Create a non-root user -RUN addgroup -g 1001 -S nodejs -RUN adduser -S svelte -u 1001 - -# Set the working directory +# Set working directory for runtime WORKDIR /app -# Copy package.json and package-lock.json +# Copy package files for production install COPY package*.json ./ +# Install only production dependencies (excludes dev dependencies) +RUN npm ci --only=production -# Install only production dependencies -RUN npm ci --only=production && npm cache clean --force +# Copy built application from build stage +COPY --from=build /app/build ./build -# Copy the built application from the previous stage -COPY --from=base --chown=svelte:nodejs /app/build ./build -COPY --from=base --chown=svelte:nodejs /app/package.json ./package.json - -# Switch to the non-root user -USER svelte - -# Expose the port the app runs on +# Expose the port the application will run on EXPOSE 3000 -# Set environment variables - DATABASE_URL can be overridden at runtime +# Set environment to production ENV NODE_ENV=production -ENV PORT=3000 -ENV DATABASE_URL="" -# Use dumb-init to handle signals properly -ENTRYPOINT ["dumb-init", "--"] - -# Start the application with environment file support +# Start the application CMD ["node", "build"] diff --git a/src/lib/WorkoutDisplay.svelte b/src/lib/WorkoutDisplay.svelte deleted file mode 100644 index fcc7e7b..0000000 --- a/src/lib/WorkoutDisplay.svelte +++ /dev/null @@ -1,148 +0,0 @@ - - -
Here be connection: {await testConnection().current}
- +Here be connection: {testConnection().current}
{#snippet pending()}loading...
diff --git a/src/lib/components/ExampleNewExercise.svelte b/src/lib/components/ExampleNewExercise.svelte new file mode 100644 index 0000000..dcabe6b --- /dev/null +++ b/src/lib/components/ExampleNewExercise.svelte @@ -0,0 +1,107 @@ + + +ExerciseField component for input forms
+ WorkoutStatCard component for display
+ workout-utils.ts for consistencyTrack your daily fitness progress