diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..33cea45 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +node_modules +.next +.noosphere-index +.env.local +.env*.local +*.log +.DS_Store +pdg +test-md.ts +tsconfig.tsbuildinfo +next-env.d.ts diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ba8a773 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:22-alpine AS base +RUN corepack enable + +FROM base AS deps +WORKDIR /app +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +FROM base AS runner +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . +# Build note index if content is available (skipped in CI, runs locally with content) +RUN [ -d content ] && node_modules/.bin/tsx scripts/build-index.ts || true +RUN node_modules/.bin/next build +RUN chmod +x docker-entrypoint.sh +ENV NODE_ENV=production +EXPOSE 3000 +ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8dbcde1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +services: + noz: + build: . + restart: unless-stopped + ports: + - "3000:3000" + volumes: + - ./content:/app/content + - ./noosphere.toml:/app/noosphere.toml:ro + - noz-index:/app/.noosphere-index + env_file: + - .env.local + + noz-studio: + build: ../noz-studio + restart: unless-stopped + ports: + - "3001:3001" + +volumes: + noz-index: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..44bf04f --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +if [ -d /app/content ]; then + echo "[noz] rebuilding note index…" + node_modules/.bin/tsx scripts/build-index.ts +fi + +exec node_modules/.bin/next start