create the podman.sh script for local testing of containerisation
This commit is contained in:
parent
fa91eb689b
commit
60e664db52
6 changed files with 38 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -11,3 +11,4 @@ node_modules
|
||||||
!.env.example
|
!.env.example
|
||||||
|
|
||||||
dev.db
|
dev.db
|
||||||
|
local.db
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"prisma:generate": "prisma generate",
|
"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 .",
|
"lint": "prettier --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
|
||||||
"format": "prettier --config ./prettierrc --write --plugin-search-dir=. .",
|
"format": "prettier --config ./prettierrc --write --plugin-search-dir=. .",
|
||||||
"test": "vitest"
|
"test": "vitest"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { defineConfig } from "prisma/config";
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
schema: "./prisma/schema.prisma",
|
schema: "./prisma/schema.prisma",
|
||||||
migrations: {
|
migrations: {
|
||||||
path: "prisma/migrations",
|
path: "./prisma/migrations",
|
||||||
},
|
},
|
||||||
datasource: {
|
datasource: {
|
||||||
url: process.env["DATABASE_URL"],
|
url: process.env["DATABASE_URL"],
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
#!/bin/sh
|
#!/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
|
exec node build
|
||||||
|
|
|
||||||
26
scripts/podman.sh
Normal file
26
scripts/podman.sh
Normal file
|
|
@ -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"
|
||||||
|
|
@ -3,6 +3,7 @@ FROM node:24-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
COPY pnpm-lock.yaml ./
|
COPY pnpm-lock.yaml ./
|
||||||
|
COPY pnpm-workspace.yaml ./
|
||||||
|
|
||||||
ENV CI=true
|
ENV CI=true
|
||||||
RUN npm i -g pnpm
|
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 prisma/
|
||||||
COPY --from=builder /app/prisma.config.ts prisma.config.ts
|
COPY --from=builder /app/prisma.config.ts prisma.config.ts
|
||||||
COPY --from=builder /app/node_modules node_modules/
|
COPY --from=builder /app/node_modules node_modules/
|
||||||
|
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
CMD [ "./entrypoint.sh" ]
|
ENTRYPOINT [ "./entrypoint.sh" ]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue