diff --git a/.gitignore b/.gitignore index eb5a316c..bd44edec 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target +build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f503b786 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM rust:latest as wasm-build + +RUN mkdir -p /usr/build/ +WORKDIR /usr/build/ + +RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + +COPY . . + +WORKDIR /usr/build/harper-wasm +RUN wasm-pack build --release + +FROM node:slim as node-build + +RUN mkdir -p /usr/build/ +WORKDIR /usr/build/ + +RUN mkdir harper-wasm + +COPY --from=wasm-build /usr/build/harper-wasm/pkg /usr/build/harper-wasm/pkg +COPY web web +COPY alice.txt . + +WORKDIR /usr/build/web + +RUN yarn install && yarn build + +FROM node:slim + +COPY --from=node-build /usr/build/web/build /usr/build/web/build +COPY --from=node-build /usr/build/web/package.json /usr/build/web/package.json +COPY --from=node-build /usr/build/web/yarn.lock /usr/build/web/yarn.lock +COPY --from=node-build /usr/build/web/node_modules /usr/build/web/node_modules + +WORKDIR /usr/build/web + +RUN yarn install + +ENV HOST=0.0.0.0 +ENV PORT=3000 + +ENTRYPOINT ["node", "build"] diff --git a/build.sh b/build.sh deleted file mode 100755 index 15a83733..00000000 --- a/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -set -eo pipefail - -R=`pwd` - -cd $R/harper-wasm -wasm-pack build --release - -cd $R/web -yarn install -yarn build diff --git a/fly.toml b/fly.toml new file mode 100644 index 00000000..ba31f963 --- /dev/null +++ b/fly.toml @@ -0,0 +1,17 @@ +app = "writewithharper" +primary_region = "den" + +[build] + +[http_service] + internal_port = 3000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 1 + processes = ["app"] + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 256 diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 00000000..6635cf55 --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1,10 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example +vite.config.js.timestamp-* +vite.config.ts.timestamp-* diff --git a/web/package.json b/web/package.json index 3e050d43..b17e701f 100644 --- a/web/package.json +++ b/web/package.json @@ -12,7 +12,8 @@ "format": "prettier --plugin-search-dir . --write ." }, "devDependencies": { - "@sveltejs/adapter-auto": "^2.0.0", + "@flydotio/dockerfile": "^0.5.0", + "@sveltejs/adapter-node": "^3.0.0", "@sveltejs/kit": "^1.20.4", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", diff --git a/web/src/app.html b/web/src/app.html index 8ab1224c..06c44ec8 100644 --- a/web/src/app.html +++ b/web/src/app.html @@ -8,8 +8,8 @@ %sveltekit.head% - -
%sveltekit.body%
+ +
%sveltekit.body%
diff --git a/web/src/lib/Editor.svelte b/web/src/lib/Editor.svelte index 31b93078..5d1c4dae 100644 --- a/web/src/lib/Editor.svelte +++ b/web/src/lib/Editor.svelte @@ -12,24 +12,29 @@ let focused: number | undefined; $: lintText(content).then((newLints) => (lints = newLints)); + $: boxHeight = calcHeight(content); - $: console.log(focused); + function calcHeight(boxContent: string): number { + let numberOfLineBreaks = (boxContent.match(/\n/g) || []).length; + let newHeight = 20 + numberOfLineBreaks * 30 + 12 + 2; + console.log(newHeight); + return newHeight; + } -
- +
+
- +

Suggestions

{#each lints as lint, i} (focused = i)}> @@ -51,7 +56,7 @@ {#each lint.suggestions as suggestion}