From eca8b6c815e2f6b204c870010bade7b7fa2e700d Mon Sep 17 00:00:00 2001 From: erangel1 Date: Thu, 4 Jun 2026 19:31:13 +0200 Subject: [PATCH] created dockerfile for deployment with dokploy. --- .dockerignore | 28 ++++++++++++++++++++++++++++ CHANGELOG.md | 1 + Dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ README.md | 26 ++++++++++++++++++++++++++ package.json | 1 + 5 files changed, 99 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6af2a18 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,28 @@ +.git +.gitignore +.dockerignore +Dockerfile + +node_modules +.pnpm-store +.npm +.yarn + +.env +.env.* +!.env.example + +.convex/local +.svelte-kit +build +dist +coverage + +.DS_Store +Thumbs.db + +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* diff --git a/CHANGELOG.md b/CHANGELOG.md index 15436c6..d6f67d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Switched the SvelteKit app to `@sveltejs/adapter-node` for production Node hosting. - Added pnpm production scripts, a production environment example, and source-control ignores for local/build artifacts. - Documented production build/start commands and Convex Auth production environment requirements. +- Added a root Dockerfile and `.dockerignore` for Dokploy Dockerfile deployments. ## 0.1.0 - 2026-06-04 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..20c6f09 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM node:24-alpine AS base + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" + +WORKDIR /app + +RUN corepack enable && corepack prepare pnpm@10.33.4 --activate + +FROM base AS deps + +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +FROM deps AS build + +ARG PUBLIC_CONVEX_URL=https://stoic-spaniel-277.eu-west-1.convex.cloud +ARG PUBLIC_CONVEX_SITE_URL=https://stoic-spaniel-277.eu-west-1.convex.site + +ENV PUBLIC_CONVEX_URL=$PUBLIC_CONVEX_URL +ENV PUBLIC_CONVEX_SITE_URL=$PUBLIC_CONVEX_SITE_URL + +COPY . . +RUN pnpm build +RUN pnpm prune --prod + +FROM node:24-alpine AS runner + +ENV NODE_ENV=production +ENV PUBLIC_CONVEX_URL=https://stoic-spaniel-277.eu-west-1.convex.cloud +ENV PUBLIC_CONVEX_SITE_URL=https://stoic-spaniel-277.eu-west-1.convex.site +ENV HOST=0.0.0.0 +ENV PORT=3000 + +WORKDIR /app + +COPY --from=build /app/build ./build +COPY --from=build /app/node_modules ./node_modules +COPY --from=build /app/package.json ./package.json + +EXPOSE 3000 + +CMD ["node", "build"] diff --git a/README.md b/README.md index e17cc03..8292f08 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,32 @@ For a single local smoke test that builds and starts the production server: pnpm prod ``` +## Docker Deployment + +The root `Dockerfile` builds the SvelteKit Node server with pnpm and runs it with `node build`. + +Build locally: + +```sh +docker build \ + --build-arg PUBLIC_CONVEX_URL=https://your-production-deployment.convex.cloud \ + --build-arg PUBLIC_CONVEX_SITE_URL=https://your-production-deployment.convex.site \ + -t journaley . +``` + +Run locally: + +```sh +docker run --rm -p 3000:3000 \ + -e PUBLIC_CONVEX_URL=https://your-production-deployment.convex.cloud \ + -e PUBLIC_CONVEX_SITE_URL=https://your-production-deployment.convex.site \ + -e HOST=0.0.0.0 \ + -e PORT=3000 \ + journaley +``` + +For Dokploy, choose a Dockerfile deployment, keep the Dockerfile path as `Dockerfile`, expose container port `3000`, and set the same environment variables in the Dokploy app settings. The public Convex URLs are also defined as Docker build args because SvelteKit's public static env values are compiled into the app during the image build. + ## Auth This project uses Convex Auth with email/password for local development. The initializer created `convex/auth.config.ts`, `convex/auth.ts`, and `convex/http.ts`; the frontend uses `@mmailaender/convex-auth-svelte` for SvelteKit auth state and auth routes. diff --git a/package.json b/package.json index 3257bc0..ba4be27 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "journaley", "version": "0.0.1", "private": true, + "packageManager": "pnpm@10.33.4", "scripts": { "dev": "vite dev", "build": "vite build",