diff --git a/.gitignore b/.gitignore
index a036acb..70a1120 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
**/target
**/Cargo.lock
woweb/assets/dist_text*
+dist/
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..53624c9
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 4312957..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/poc.iml b/.idea/poc.iml
deleted file mode 100644
index 53e954b..0000000
--- a/.idea/poc.iml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index e065794..cf11b5a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -121,9 +121,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block-buffer"
-version = "0.10.3"
+version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
@@ -898,9 +898,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
-version = "1.0.153"
+version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3a382c72b4ba118526e187430bb4963cd6d55051ebf13d9b25574d379cc98d20"
+checksum = "8cdd151213925e7f1ab45a9bbfb129316bd00799784b174b7cc7bcd16961c49e"
dependencies = [
"serde_derive",
]
@@ -918,9 +918,9 @@ dependencies = [
[[package]]
name = "serde_derive"
-version = "1.0.153"
+version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1ef476a5790f0f6decbc66726b6e5d63680ed518283e64c7df415989d880954f"
+checksum = "4fc80d722935453bcafdc2c9a73cd6fac4dc1938f0346035d84bf99fa9e33217"
dependencies = [
"proc-macro2",
"quote",
@@ -1317,9 +1317,9 @@ dependencies = [
[[package]]
name = "unicode-bidi"
-version = "0.3.10"
+version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58"
+checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c"
[[package]]
name = "unicode-ident"
diff --git a/Cargo.toml b/Cargo.toml
index be4055b..c9c2e9f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,3 +5,6 @@ members = [
"dist_text_js",
"woweb"
]
+
+[profile.release]
+strip = true
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 9d5f316..a4ef92a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,25 +4,25 @@ ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN apk add --no-cache \
musl-dev \
- wasm-pack
+ wasm-pack \
+ make
RUN rustup target add wasm32-unknown-unknown
ADD . /src
WORKDIR /src
-RUN cargo build --release
-RUN strip target/release/woweb
+RUN make release
RUN adduser -D woweb
-RUN sed -i 's|ws://localhost:3000/ws|wss://woweb.vanwa.ch/ws|' woweb/assets/index.js
+RUN sed -i 's|ws://localhost:3000/ws|wss://woweb.vanwa.ch/ws|' dist/assets/index.js
FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
-COPY --from=builder /src/target/release/woweb "/opt/woweb"
-COPY --from=builder /src/woweb/assets "/opt/assets"
+COPY --from=builder /src/dist/woweb "/opt/woweb"
+COPY --from=builder /src/dist/assets "/opt/assets"
EXPOSE 3000
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6a07330
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,38 @@
+WASM_PKG_DIR = dist_text_js/pkg
+ASSET_DIR = woweb/assets
+WASM_JS = dist_text_js.js
+WASM_BG = dist_text_js_bg.wasm
+WASM_JS_PKG = $(WASM_PKG_DIR)/$(WASM_JS)
+WASM_BG_PKG = $(WASM_PKG_DIR)/$(WASM_BG)
+WASM_JS_ASSET = $(ASSET_DIR)/$(WASM_JS)
+WASM_BG_ASSET = $(ASSET_DIR)/$(WASM_BG)
+DIST_DIR = dist
+
+.PHONY: default all wasm serve clean
+
+default: all
+all: wasm
+wasm: $(WASM_JS_ASSET) $(WASM_BG_ASSET)
+
+$(WASM_JS_ASSET) $(WASM_BG_ASSET): dist_text_js/src/lib.rs
+ cd dist_text_js; \
+ wasm-pack build --target web --release --no-typescript
+
+ cp $(WASM_JS_PKG) $(WASM_JS_ASSET)
+ cp $(WASM_BG_PKG) $(WASM_BG_ASSET)
+
+serve: wasm
+ cargo run --package woweb
+
+release: $(DIST_DIR) wasm
+ cargo build --package woweb --release
+ cp target/release/woweb $(DIST_DIR)
+ cp -r $(ASSET_DIR) $(DIST_DIR)
+
+$(DIST_DIR):
+ mkdir -p $(DIST_DIR)
+
+clean:
+ cargo clean
+ rm -rf $(WASM_PKG_DIR)
+ rm -f $(ASSET_DIR)/dist_text*
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..82b1203
--- /dev/null
+++ b/README.md
@@ -0,0 +1,9 @@
+# Prerequisites
+- [make](https://en.wikipedia.org/wiki/Make_(software))
+- [wasm-pack](https://github.com/rustwasm/wasm-pack)
+- [rustup](https://rustup.rs/)
+- [cargo](https://github.com/rust-lang/cargo)
+
+```
+rustup target add wasm32-unknown-unknown
+```
\ No newline at end of file
diff --git a/dist_text_js/Cargo.toml b/dist_text_js/Cargo.toml
index cecd323..dbc2c74 100644
--- a/dist_text_js/Cargo.toml
+++ b/dist_text_js/Cargo.toml
@@ -10,4 +10,4 @@ crate-type = ["cdylib"]
dist_text = { path = "../dist_text" }
serde = { version = "1.0.153", features = ["derive"] }
serde-wasm-bindgen = "0.5.0"
-wasm-bindgen = "0.2.84"
\ No newline at end of file
+wasm-bindgen = "0.2.84"
diff --git a/woweb/.idea/.gitignore b/woweb/.idea/.gitignore
deleted file mode 100644
index 13566b8..0000000
--- a/woweb/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/woweb/.idea/modules.xml b/woweb/.idea/modules.xml
deleted file mode 100644
index ea8c3ec..0000000
--- a/woweb/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/woweb/.idea/vcs.xml b/woweb/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/woweb/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/woweb/.idea/woweb-poc.iml b/woweb/.idea/woweb-poc.iml
deleted file mode 100644
index c254557..0000000
--- a/woweb/.idea/woweb-poc.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/woweb/Cargo.toml b/woweb/Cargo.toml
index 7ebd3f3..9d0f045 100644
--- a/woweb/Cargo.toml
+++ b/woweb/Cargo.toml
@@ -2,7 +2,6 @@
name = "woweb"
version = "0.2.0"
edition = "2021"
-build = "build.rs"
[dependencies]
dist_text = { path = "../dist_text" }
diff --git a/woweb/build.rs b/woweb/build.rs
deleted file mode 100644
index d835b8f..0000000
--- a/woweb/build.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-use std::env;
-use std::fs;
-use std::path::Path;
-use std::process::Command;
-
-fn main() {
- let woweb_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
- let woweb_path = Path::new(&woweb_dir);
- let woweb_asset_path = woweb_path.join("assets");
- let dist_text_path = woweb_path.parent().unwrap().join("dist_text_js");
- let dist_text_pkg_path = dist_text_path.join("pkg");
-
- Command::new("wasm-pack")
- .args(&["build", "--target", "web", "--release", "--no-typescript"])
- .current_dir(dist_text_path)
- .status()
- .unwrap();
-
- let js_path_src = dist_text_pkg_path.join("dist_text_js.js");
- let js_path_dest = woweb_asset_path.join("dist_text_js.js");
-
- let wasm_path_src = dist_text_pkg_path.join("dist_text_js_bg.wasm");
- let wasm_path_dest = woweb_asset_path.join("dist_text_js_bg.wasm");
-
- let _ = fs::copy(js_path_src, js_path_dest);
- let _ = fs::copy(wasm_path_src, wasm_path_dest);
-
- println!("cargo:rerun-if-changed=../dist_text_js/**/*.rs");
-}