diff --git a/.env.development b/.env.development index c1383a3..e0a13d7 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,16 @@ -PGHOST=localhost +NODE_ENV=development +DOMAIN=bitmill.io +PROTOCOL=https +HOSTNAME=brf.local +PORT=null +FASTIFY_HOST=0.0.0.0 +FASTIFY_PORT=1337 +LOG_LEVEL=debug +LOG_STREAM=console +PGHOST=postgres PGPORT=5432 PGDATABASE=brf_books PGUSER=brf_books PGPASSWORD=brf_books +REDIS_HOST=redis +VITE_HMR_PROXY=true diff --git a/Dockerfile b/Dockerfile index b4c39f5..9649a8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,24 @@ -FROM node:23-alpine AS base +FROM node:25-alpine AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" -RUN corepack enable pnpm ARG UID=1000 ARG GID=1000 -RUN apk add --no-cache git shadow +RUN apk add --no-cache shadow +RUN npm install -g pnpm@^10.23.0 RUN groupmod -g $GID node # this does not seem to be having full effect. eg /home/node gets 1337:1000 ownership despite group node having id 1337 RUN usermod -u $UID -g node node USER node -RUN mkdir /home/node/startbit -RUN git config --global --add safe.directory /home/node/startbit -WORKDIR /home/node/startbit +RUN mkdir /home/node/brf_books +WORKDIR /home/node/brf_books -COPY --chown=node pnpm-lock.yaml package.json ./ +COPY --chown=node pnpm-lock.yaml package.json . RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -COPY --chown=node \ - .env.secrets \ - vite.config.js ./ +COPY --chown=node vite.config.js . # -------- development -------- # FROM base AS development @@ -42,4 +39,4 @@ RUN pnpm run build COPY --chown=node .git .git -CMD pnpm run start server/index.ts +CMD pnpm run start diff --git a/client/client.d.ts b/client/client.d.ts new file mode 100644 index 0000000..12da21c --- /dev/null +++ b/client/client.d.ts @@ -0,0 +1,6 @@ +declare module '*.module.scss' { + const classNames: Record + export default classNames +} + +declare module '*.scss' diff --git a/client/public/client.ts b/client/public/client.ts new file mode 100644 index 0000000..48fe099 --- /dev/null +++ b/client/public/client.ts @@ -0,0 +1,8 @@ +import './styles/main.scss' + +import { h, hydrate } from 'preact' +import App from './components/app.tsx' + +const STATE = typeof __STATE__ !== 'undefined' ? __STATE__ : undefined + +hydrate(h(App, STATE), document.body) diff --git a/client/public/components/app.module.scss b/client/public/components/app.module.scss new file mode 100644 index 0000000..55e7d1b --- /dev/null +++ b/client/public/components/app.module.scss @@ -0,0 +1,3 @@ +.title { + font-size: 120px; +} diff --git a/client/public/components/app.tsx b/client/public/components/app.tsx new file mode 100644 index 0000000..8c121f6 --- /dev/null +++ b/client/public/components/app.tsx @@ -0,0 +1,36 @@ +import { h } from 'preact' +import { Router } from 'preact-router' +import Head from './head.ts' +import Footer from './footer.tsx' +import Header from './header.tsx' +import ErrorPage from './error_page.tsx' +import routes from '../routes.ts' + +import s from './app.module.scss' + +export default function App({ error, url, title }) { + return ( +
+ + {title || 'Untitled'} + + +
+ +
+ {error ? ( + + ) : ( + + {routes.map((route) => ( + // @ts-ignore + + ))} + + )} +
+ +
+
+ ) +} diff --git a/client/public/components/error_page.tsx b/client/public/components/error_page.tsx new file mode 100644 index 0000000..35764e1 --- /dev/null +++ b/client/public/components/error_page.tsx @@ -0,0 +1,15 @@ +import { h } from 'preact' +import Head from './head.ts' + +const OtherPage = ({ error }) => ( +
+ + : Error + + +

Oh no!

+
{JSON.stringify(error, ['name', ...Object.getOwnPropertyNames(error)], '  ')}
+
+) + +export default OtherPage diff --git a/client/public/components/footer.tsx b/client/public/components/footer.tsx new file mode 100644 index 0000000..861be7c --- /dev/null +++ b/client/public/components/footer.tsx @@ -0,0 +1,5 @@ +import { h } from 'preact' + +const Footer = () =>