diff --git a/apps/api/.dockerignore b/apps/api/.dockerignore new file mode 100644 index 0000000..ca67891 --- /dev/null +++ b/apps/api/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.tmp +data +drizzle/meta diff --git a/apps/api/.env.example b/apps/api/.env.example new file mode 100644 index 0000000..53a2b25 --- /dev/null +++ b/apps/api/.env.example @@ -0,0 +1,4 @@ +DATABASE_URL=file:./data/app.db +BETTER_AUTH_SECRET=change-me-to-a-long-random-string +BETTER_AUTH_URL=http://localhost:3000 +PORT=3000 diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile new file mode 100644 index 0000000..7629549 --- /dev/null +++ b/apps/api/Dockerfile @@ -0,0 +1,27 @@ +FROM node:22-alpine AS base +RUN corepack enable +WORKDIR /repo + +# Copy workspace manifests for cached install +COPY package.json yarn.lock .yarnrc.yml ./ +COPY .yarn/ ./.yarn/ +COPY packages/shared/package.json ./packages/shared/package.json +COPY apps/api/package.json ./apps/api/package.json +# Copy the other workspace manifests too, so the workspace graph matches the +# lockfile (otherwise Yarn errors on a mismatch). `focus` still installs ONLY +# the @solelog/api subtree, so mobile/web deps are not pulled. +COPY apps/mobile/package.json ./apps/mobile/package.json +COPY apps/web/package.json ./apps/web/package.json + +RUN yarn workspaces focus @solelog/api + +# Copy sources +COPY packages/shared/ ./packages/shared/ +COPY apps/api/ ./apps/api/ + +WORKDIR /repo/apps/api +ENV NODE_ENV=production +EXPOSE 3000 + +# Apply migrations, then start the server +CMD ["sh", "-c", "yarn db:migrate && yarn start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..61375b7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +services: + api: + build: + context: . + dockerfile: apps/api/Dockerfile + ports: + - '3000:3000' + environment: + DATABASE_URL: file:/data/app.db + BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:-change-me-to-a-long-random-string} + BETTER_AUTH_URL: http://localhost:3000 + PORT: '3000' + volumes: + - solelog_db:/data + +volumes: + solelog_db: diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..70b4602 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,20 @@ +# SoleLog docs + +- [Roadmap & project overview](./roadmap.md) +- [Plans](./plans/) + +## Running the backend (Phase 0) + +Local (dev): +```bash +yarn install +cp apps/api/.env.example apps/api/.env # edit BETTER_AUTH_SECRET +yarn workspace @solelog/api db:migrate +yarn workspace @solelog/api dev +``` + +Docker (whole stack): +```bash +docker compose up --build +# health: curl http://localhost:3000/health +```