diff --git a/.gitignore b/.gitignore index 5588a4e..10df2f4 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ node_modules !.env.example dev.db +local.db diff --git a/package.json b/package.json index 06030ad..6ec6213 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "check": "svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", "prisma:generate": "prisma generate", - "prisma:push": "prisma db push", + "prisma:migrate": "prisma migrate dev", + "prisma:deploy": "prisma migrate deploy", "lint": "prettier --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", "format": "prettier --config ./prettierrc --write --plugin-search-dir=. .", "test": "vitest" diff --git a/prisma.config.ts b/prisma.config.ts index dfa38b2..8d2409d 100644 --- a/prisma.config.ts +++ b/prisma.config.ts @@ -6,7 +6,7 @@ import { defineConfig } from "prisma/config"; export default defineConfig({ schema: "./prisma/schema.prisma", migrations: { - path: "prisma/migrations", + path: "./prisma/migrations", }, datasource: { url: process.env["DATABASE_URL"], diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index fe0824f..18fedf0 100644 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -1,4 +1,7 @@ #!/bin/sh -# Commented out while i figure out what's locking it -# npx prisma migrate dev + +#Run the prisma:deploy npm script +npm run prisma:deploy + +# Start the server exec node build diff --git a/scripts/podman.sh b/scripts/podman.sh new file mode 100644 index 0000000..c92f11a --- /dev/null +++ b/scripts/podman.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -euo pipefail + +CONTAINER_NAME="website" +CONTAINER_TAG="thomaswilson/website:latest" +DATABASE_URL="file:/data/local.db" + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +DATA_DIR="${ROOT_DIR}/data" +LOCAL_VOLUME="${DATA_DIR}:/data:Z" + +mkdir -p "${DATA_DIR}" + +podman container stop "$CONTAINER_NAME" || true +podman container rm "$CONTAINER_NAME" || true + +podman build -t "$CONTAINER_TAG" -f "$ROOT_DIR/web.Dockerfile" "$ROOT_DIR" + +podman run -d \ + -p 3000:3000 \ + --name "$CONTAINER_NAME" \ + -e PRIVATE_DATABASE_URL="$DATABASE_URL" \ + -e DATABASE_URL="$DATABASE_URL" \ + -v "$LOCAL_VOLUME" \ + --restart unless-stopped \ + "$CONTAINER_TAG" diff --git a/web.Dockerfile b/web.Dockerfile index d0b0694..bdf4e39 100644 --- a/web.Dockerfile +++ b/web.Dockerfile @@ -3,6 +3,7 @@ FROM node:24-alpine AS builder WORKDIR /app COPY package*.json ./ COPY pnpm-lock.yaml ./ +COPY pnpm-workspace.yaml ./ ENV CI=true RUN npm i -g pnpm @@ -20,8 +21,9 @@ COPY --from=builder /app/build build/ COPY --from=builder /app/prisma prisma/ COPY --from=builder /app/prisma.config.ts prisma.config.ts COPY --from=builder /app/node_modules node_modules/ + COPY package.json . EXPOSE 3000 ENV NODE_ENV=production VOLUME /data -CMD [ "./entrypoint.sh" ] +ENTRYPOINT [ "./entrypoint.sh" ]