diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..ae508b60 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +* + +!webapp/** +!bindings/nodejs/** +!bindings/wasm/** +!xlsx/** +!base/** diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..79e5bc96 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM node:24-alpine AS builder +WORKDIR /app +RUN apk add --no-cache curl build-base python3 +RUN curl https://sh.rustup.rs -sSf | sh -s - -y +ENV PATH="/root/.cargo/bin:${PATH}" +RUN cargo install wasm-pack +COPY . . +RUN cd /app/bindings/nodejs && npm install && npm run build +RUN npm uninstall tsc && npm install -D typescript && cd /app/bindings/wasm && make +RUN cd /app/webapp/IronCalc && npm install && npm run build +RUN cd /app/webapp/app.ironcalc.com/frontend && npm install && npm run build +RUN cd /app/webapp/app.ironcalc.com/server && cargo build --release + + +FROM caddy:2.10.0-alpine + +RUN apk add build-base musl-dev +COPY --from=builder /app/webapp/app.ironcalc.com/frontend/dist /usr/share/nginx/html +COPY --from=builder /app/webapp/app.ironcalc.com/server/target/release/ironcalc_server /usr/local/bin/ironcalc_server +COPY webapp/app.ironcalc.com/Caddyfile /etc/caddy/Caddyfile +COPY webapp/app.ironcalc.com/server/Rocket.toml . + +EXPOSE 2080 diff --git a/webapp/app.ironcalc.com/frontend/src/components/rpc.ts b/webapp/app.ironcalc.com/frontend/src/components/rpc.ts index bb1dcfdd..9626ad78 100644 --- a/webapp/app.ironcalc.com/frontend/src/components/rpc.ts +++ b/webapp/app.ironcalc.com/frontend/src/components/rpc.ts @@ -38,9 +38,14 @@ export async function uploadFile( return blob; } +const buildApiUrl = (endpoint: string): string => { + const baseUrl: string = import.meta.env.API_BASE_URL || ""; + return `${(baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl )}${endpoint}`; +} + export async function get_model(modelHash: string): Promise { return new Uint8Array( - await (await fetch(`/api/model/${modelHash}`)).arrayBuffer(), + await (await fetch(buildApiUrl(`/api/model/${modelHash}`))).arrayBuffer(), ); } @@ -48,7 +53,7 @@ export async function get_documentation_model( filename: string, ): Promise { return new Uint8Array( - await (await fetch(`/models/${filename}.ic`)).arrayBuffer(), + await (await fetch(buildApiUrl(`/models/${filename}.ic`))).arrayBuffer(), ); } diff --git a/webapp/app.ironcalc.com/server/.gitignore b/webapp/app.ironcalc.com/server/.gitignore index e420ee4b..abc4819f 100644 --- a/webapp/app.ironcalc.com/server/.gitignore +++ b/webapp/app.ironcalc.com/server/.gitignore @@ -1 +1,3 @@ target/* +debug/* +.rustc_info.json