summaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile171
1 files changed, 171 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..ff86675
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,171 @@
+# syntax=docker/dockerfile:1
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# This file is part of Wolfree.
+# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+FROM alpine
+
+WORKDIR /app/
+
+# Install all dependencies.
+
+RUN \
+ apk add \
+ -- \
+ wget \
+ npm \
+ gcc \
+ rustup \
+ ;
+
+RUN \
+ rustup-init -y
+
+COPY \
+ ./docusaurus/package.json \
+ ./docusaurus/package.json
+
+RUN \
+ npm install \
+ --prefix ./docusaurus/ \
+ -- \
+ ;
+
+# WolframAlpha LLC prebuilt the website and kindly deployed it on the Internet.
+# We can run Wget to download the web pages and save them as static pages.
+
+RUN \
+ wget \
+ --directory-prefix=./docusaurus/static/ \
+ --no-host-directories \
+ --page-requisites \
+ --convert-links \
+ --no-verbose \
+ -- \
+ 'https://www.wolframalpha.com/input/index.html' \
+ 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js' \
+ 'https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.5/purify.min.js' \
+ ; \
+ : \
+ ;
+
+RUN \
+ sed \
+ -e 's|.*js...static.chunks...........||' \
+ -e 's|"........js.....miniCssF.*|.js\n|' \
+ -e 's|:"|.|g' \
+ -e 's|",|.js\n|g' \
+ -- \
+ ./docusaurus/static/_next/static/chunks/webpack-*.js \
+ | \
+ wget \
+ --directory-prefix=./docusaurus/static/ \
+ --no-host-directories \
+ --page-requisites \
+ --convert-links \
+ --no-verbose \
+ --input-file=- \
+ --base=https://www.wolframalpha.com/_next/static/chunks/ \
+ -- \
+ ; \
+ : \
+ ;
+
+RUN \
+ sed \
+ -e 's|.*return.static.css.....||' \
+ -e 's|.........css.......function.*|.css\n|' \
+ -e 's|[0-9]*:"||g' \
+ -e 's|",|.css\n|g' \
+ -- \
+ ./docusaurus/static/_next/static/chunks/webpack-*.js \
+ | \
+ wget \
+ --directory-prefix=./docusaurus/static/ \
+ --no-host-directories \
+ --page-requisites \
+ --convert-links \
+ --no-verbose \
+ --input-file=- \
+ --base=https://www.wolframalpha.com/_next/static/css/ \
+ -- \
+ ; \
+ : \
+ ;
+
+# Delete unused large files on the static website.
+
+RUN \
+ truncate \
+ -s 0 \
+ -- \
+ ./docusaurus/static/_next/static/images/* \
+ ;
+
+# Build the Docusaurus static website.
+
+COPY \
+ ./docusaurus/ \
+ ./docusaurus/
+
+RUN \
+ npm run \
+ --prefix ./docusaurus/ \
+ -- \
+ build \
+ ;
+
+# Lint the source code and run the Rust program.
+# The Rust program customizes the static pages.
+
+COPY \
+ ./rust/ \
+ ./rust/
+
+RUN \
+ PATH="$HOME/.cargo/bin:$PATH" \
+ cargo clippy \
+ --manifest-path ./rust/wolfree_libredirect_patch/Cargo.toml \
+ -- \
+ --warn clippy::all \
+ --warn clippy::cargo \
+ --warn clippy::nursery \
+ --warn clippy::pedantic \
+ --warn clippy::restriction \
+ ;
+
+RUN \
+ PATH="$HOME/.cargo/bin:$PATH" \
+ cargo clippy \
+ --manifest-path ./rust/wolfree_sed_in_place/Cargo.toml \
+ -- \
+ --warn clippy::all \
+ --warn clippy::cargo \
+ --warn clippy::nursery \
+ --warn clippy::pedantic \
+ --warn clippy::restriction \
+ ;
+
+# Optionally, customize Wolfree instances to suit LibRedirect.
+# https://github.com/libredirect/browser_extension/issues/425
+# To integrate Wolfree with LibRedirect, please delete the number sign at the beginning of the following line.
+# RUN PATH="$HOME/.cargo/bin:$PATH" cargo run --manifest-path ./rust/wolfree_libredirect_patch/Cargo.toml -- ;
+
+RUN PATH="$HOME/.cargo/bin:$PATH" cargo run --manifest-path ./rust/wolfree_sed_in_place/Cargo.toml -- ;
+
+# Optimizing builds with cache management | Docker Documentation
+# https://docs.docker.com/build/cache/
+# Because a change causes a rebuild for steps that follow,
+# try to make expensive steps appear near the beginning of the Dockerfile.
+# Steps that change often should appear near the end of the Dockerfile to avoid triggering rebuilds of layers that haven't changed.
+
+CMD \
+ npm run \
+ --prefix ./docusaurus/ \
+ -- \
+ serve \
+ --port 80 \
+ --host localhost \
+ ;
+
+EXPOSE 80