diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 4cd6dc6..5a2396c 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,35 +1,20 @@ FROM docker.io/oven/bun as base -WORKDIR /usr/src/app # install dependencies into temp directory FROM base AS install -RUN mkdir -p /temp/dev -COPY package.json bun.lockb /temp/dev/ -RUN cd /temp/dev && bun install --frozen-lockfile +WORKDIR /modules +COPY package.json bun.lockb /modules/ +RUN bun install --frozen-lockfile --production -# install with --production (exclude devDependencies) -RUN mkdir -p /temp/prod -COPY package.json bun.lockb /temp/prod/ -RUN cd /temp/prod && bun install --frozen-lockfile --production - -# copy node_modules from temp directory -# then copy all (non-ignored) project files into the image -FROM base AS prerelease -COPY --from=install /temp/dev/node_modules node_modules -COPY . . - -# [optional] tests & build -ENV NODE_ENV=production -RUN bun test -RUN bun run build # copy production dependencies and source code into final image FROM base AS release -COPY --from=install /temp/prod/node_modules node_modules -COPY --from=prerelease /usr/src/app/index.ts . -COPY --from=prerelease /usr/src/app/package.json . +WORKDIR /usr/src/app + +COPY --from=install /modules/node_modules node_modules +COPY src . # run the app USER bun EXPOSE 3000/tcp -ENTRYPOINT [ "bun", "run", "index.ts" ] \ No newline at end of file +ENTRYPOINT [ "bun", "run", "index.tsx" ] diff --git a/frontend/package.json b/frontend/package.json index c172e05..ac60c22 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,9 +4,9 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "bun run tailwind:dev | bun run elxsia:dev", - "elxsia:dev": "bun --watch src/index.ts", + "elxsia:dev": "bun --watch src/index.tsx", "build": "bun run tailwind:build", - "start": "bun run src/index.ts", + "start": "bun run src/index.tsx", "tailwind:build": "bunx tailwindcss -i ./src/style.css -o ./public/style.css --minify", "tailwind:dev": "bunx tailwindcss -i ./src/style.css -o ./public/style.css --watch" }, diff --git a/frontend/src/index.ts b/frontend/src/index.tsx similarity index 86% rename from frontend/src/index.ts rename to frontend/src/index.tsx index 5e30d98..e28bacd 100644 --- a/frontend/src/index.ts +++ b/frontend/src/index.tsx @@ -6,6 +6,8 @@ import { staticPlugin } from "@elysiajs/static"; // // @ts-ignore // import data from "../package.json"; +import { HomeLayout } from "./layout"; + export const server = new Elysia() .use(html()) .use(staticPlugin()) @@ -17,12 +19,11 @@ export const server = new Elysia() .onError(({ code, error }) => { console.error(code, error); }) - .get("/", () => "Hello World") + .get("/", ({html}) => html(
hello world
)) .listen(Bun.env["PORT"] ?? 3000); - console.log( `app is running at ${server.server?.hostname}:${server.server?.port}`, ); diff --git a/frontend/src/layout.tsx b/frontend/src/layout.tsx new file mode 100644 index 0000000..92c751f --- /dev/null +++ b/frontend/src/layout.tsx @@ -0,0 +1,23 @@ +import { html } from "@elysiajs/html"; +const HomeLayout = ({ children }: elements.Children) => ` + + + + + + // not working + BETH STACK + + + BETH STACK +
+ Bun 1.0 + Elysia + Turso + Htmx +
+ ${children} + +`; + +export { HomeLayout } diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 1ca2350..7c463bc 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -1,5 +1,9 @@ { "compilerOptions": { + + "jsx": "react", + "jsxFactory": "Html.createElement", + "jsxFragmentFactory": "Html.Fragment", /* Visit https://aka.ms/tsconfig to read more about this file */ /* Projects */