From 7a3bbecf2b2f3518461760c0dbb98189c8eb39ae Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Thu, 5 Sep 2019 21:50:08 +0000 Subject: [PATCH] PR 1.0.0-beta.2 (#6) --- .dockerignore | 9 +++++++++ .drone.yml | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ .vscode/settings.json | 2 ++ Cargo.lock | 617 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------- Cargo.toml | 14 ++++++++++---- Dockerfile | 8 -------- Makefile | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Tasks.Dev.toml | 17 +++++++++++++++++ Tasks.Prod.toml | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 29 ----------------------------- docker/alpine/Dockerfile.tmpl | 26 ++++++++++++++++++++++++++ docker/envoy/.dockerignore | 9 +++++++++ docker/envoy/docker-compose.yml | 36 ++++++++++++++++++++++++++++++++++++ docker/envoy/docker-entrypoint.sh | 6 ++++++ docker/envoy/sw.envoy.dockerfile | 15 +++++++++++++++ docker/scratch/Dockerfile.tmpl | 18 ++++++++++++++++++ public/assets/favicon.ico | Bin 0 -> 23229 bytes public/assets/main.css | 5 +++++ public/index.html | 14 ++++++++++---- scripts/version.sh | 37 +++++++++++++++++++++++++++++++++++++ src/env.rs | 33 +++++++++++++++++++++++++++++++++ src/gzip.rs | 26 ++++++++++++++++++++++++++ src/logger.rs | 24 ++++++++++++++++++++++++ src/main.rs | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 26 files changed, 1192 insertions(+), 215 deletions(-) create mode 100644 .dockerignore create mode 100644 .drone.yml delete mode 100644 Dockerfile create mode 100644 README.md create mode 100644 Tasks.Dev.toml create mode 100644 Tasks.Prod.toml delete mode 100644 docker-compose.yml create mode 100644 docker/alpine/Dockerfile.tmpl create mode 100644 docker/envoy/.dockerignore create mode 100644 docker/envoy/docker-compose.yml create mode 100644 docker/envoy/docker-entrypoint.sh create mode 100644 docker/envoy/sw.envoy.dockerfile create mode 100644 docker/scratch/Dockerfile.tmpl create mode 100644 public/assets/favicon.ico create mode 100644 public/assets/main.css create mode 100755 scripts/version.sh create mode 100644 src/env.rs create mode 100644 src/gzip.rs create mode 100644 src/logger.rs diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e1acb5a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +*.~ +.git +**/*.gz +**/*.log +**/*.tar +**/.DS_Store +.gitignore +*docker-compose* +Makefile diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..11415be --- /dev/null +++ b/.drone.yml @@ -0,0 +1,138 @@ +pipeline: + restore-cache: + image: drillster/drone-volume-cache + restore: true + mount: + - /home/rust/.cargo/git + - /home/rust/.cargo/registry + - ./target + volumes: + - /tmp/cache:/cache + + # DEVELOPMENT + + test: + image: ekidd/rust-musl-builder:stable + group: development + commands: + - make test + when: + event: push + + # PRODUCTION + + build-release: + image: ekidd/rust-musl-builder:stable + group: production + commands: + - make prod.release + when: + branch: master + event: tag + + publish-image-scratch: + image: plugins/docker + group: production + registry: registry.joseluisq.net + repo: registry.joseluisq.net/static-web-server + dockerfile: ./docker/scratch/Dockerfile + username: + from_secret: registry_username + password: + from_secret: registry_password + auto_tag: true + build_args: + - DOCKER_IMAGE_VERSION=${DRONE_TAG} + when: + branch: master + event: tag + + publish-image-alpine: + image: plugins/docker + group: production + registry: registry.joseluisq.net + repo: registry.joseluisq.net/static-web-server + dockerfile: ./docker/alpine/Dockerfile + username: + from_secret: registry_username + password: + from_secret: registry_password + auto_tag: true + auto_tag_suffix: alpine + build_args: + - DOCKER_IMAGE_VERSION=${DRONE_TAG}-alpine + when: + branch: master + event: tag + + publish-gitea-release: + image: plugins/gitea-release + group: production + api_key: + from_secret: gitea_token + base_url: https://git.joseluisq.net/ + files: + - ./bin/*.tar.gz + - ./bin/*.zip + prerelease: true + checksum: + - md5 + - sha1 + when: + branch: master + event: tag + + # publish-github-release: + # image: plugins/github-release + # group: production + # api_key: + # from_secret: github_token + # files: + # - ./bin/*.tar.gz + # - ./bin/*.zip + # prerelease: true + # checksum: + # - md5 + # - sha1 + # when: + # branch: master + # event: tag + + publish-image-scratch-docker-hub: + image: plugins/docker + group: production + repo: joseluisq/static-web-server + dockerfile: ./docker/scratch/Dockerfile + username: + from_secret: dockerhub_username + password: + from_secret: dockerhub_password + auto_tag: true + when: + branch: master + event: tag + + publish-image-alpine-docker-hub: + image: plugins/docker + group: production + repo: joseluisq/static-web-server + dockerfile: ./docker/alpine/Dockerfile + username: + from_secret: dockerhub_username + password: + from_secret: dockerhub_password + auto_tag: true + auto_tag_suffix: alpine + when: + branch: master + event: tag + + rebuild-cache: + image: drillster/drone-volume-cache + rebuild: true + mount: + - /home/rust/.cargo/git + - /home/rust/.cargo/registry + - ./target + volumes: + - /tmp/cache:/cache diff --git a/.gitignore b/.gitignore index 13356e7..67d7a6b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ **/*.log /*.html **/*.bin +**/*.iml +**/.idea diff --git a/.vscode/settings.json b/.vscode/settings.json index cca5179..7ce5bb9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,7 @@ { "editor.formatOnSave": true, + "editor.insertSpaces": true, + "editor.tabSize": 4, "files.insertFinalNewline": true, "rust.build_on_save": true, "rust.clippy_preference": "on", diff --git a/Cargo.lock b/Cargo.lock index 0931982..eb66093 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,41 +1,93 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "adler32" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "aho-corasick" -version = "0.5.3" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "atty" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "autocfg" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "base64" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "safemem 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitflags" -version = "1.0.4" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bumpalo" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.2.7" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cc" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "chrono" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -43,51 +95,72 @@ name = "csv" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "env_logger" -version = "0.3.5" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "fuchsia-zircon" +name = "envy" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" +name = "flate2" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "httparse" -version = "1.3.3" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "humantime" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "hyper" -version = "0.10.15" +version = "0.10.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -101,31 +174,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "iron" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "mime_guess 1.8.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)", "modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "js-sys" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -134,8 +206,13 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "libc" -version = "0.2.44" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -143,15 +220,15 @@ name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -161,19 +238,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memchr" -version = "0.1.11" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" -version = "1.0.2" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "mime" @@ -185,26 +259,60 @@ dependencies = [ [[package]] name = "mime_guess" -version = "1.8.6" +version = "1.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "phf 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_codegen 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", + "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "miniz-sys" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "modifier" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "num-integer" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "num_cpus" -version = "1.8.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -214,33 +322,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "phf" -version = "0.7.23" +version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf_codegen" -version = "0.7.23" +version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf_generator" -version = "0.7.23" +version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf_shared" -version = "0.7.23" +version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -253,12 +361,12 @@ version = "0.1.0" source = "git+https://github.com/integer32llc/playground-middleware.git#146df5e79210fc21ded487cf41fcb4e1ae1a347a" dependencies = [ "csv 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "iron 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "iron 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mime_guess 1.8.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -271,101 +379,235 @@ dependencies = [ ] [[package]] +name = "proc-macro2" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quick-error" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "rand" -version = "0.5.5" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "redox_syscall" -version = "0.1.43" +name = "rand_hc" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "regex" -version = "0.1.80" +name = "rand_isaac" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "regex-syntax" -version = "0.3.9" +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_os" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "rust-web-server" -version = "1.0.0" +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "iron 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "playground-middleware 0.1.0 (git+https://github.com/integer32llc/playground-middleware.git)", + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "regex" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "regex-syntax" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "rustc-serialize" version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "safemem" -version = "0.3.0" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "serde_derive" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "siphasher" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "thread-id" -version = "2.0.0" +name = "smallvec" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "static-web-server" +version = "1.0.0-beta.1" +dependencies = [ + "chrono 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", + "envy 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "iron 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "playground-middleware 0.1.0 (git+https://github.com/integer32llc/playground-middleware.git)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termcolor" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thread_local" -version = "0.2.7" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "time" -version = "0.1.40" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -404,7 +646,15 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.7" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-xid" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -426,23 +676,62 @@ dependencies = [ ] [[package]] -name = "utf8-ranges" -version = "0.1.3" +name = "version_check" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "version_check" -version = "0.1.5" +name = "wasm-bindgen" +version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "winapi" -version = "0.2.8" +name = "wasm-bindgen-backend" +version = "0.2.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -450,78 +739,124 @@ dependencies = [ ] [[package]] -name = "winapi-build" -version = "0.1.1" +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "winapi-util" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wincolor" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] -"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" +"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" -"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" +"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" +"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +"checksum chrono 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "27429a03ca54100bf6bdc726c09adc46a74187ac93f9ce96dc7aaa9594ebf707" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum csv 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7ef22b37c7a51c564a365892c012dc0271221fdcc64c69b19ba4d6fa8bd96d9c" -"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" -"checksum hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)" = "df0caae6b71d266b91b4a83111a61d2b94ed2e2bea024c532b933dcff867e58c" +"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" +"checksum envy 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "20664407d5097b5a861dffb0c32af2be7215a0050415cb50232aec36d73f69df" +"checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" +"checksum hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -"checksum iron 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d8e17268922834707e1c29e8badbf9c712c9c43378e1b6a3388946baff10be2" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum iron 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d308ca2d884650a8bf9ed2ff4cb13fbb2207b71f64cda11dc9b892067295e8" +"checksum js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "1efc4f2a556c58e79c5500912e221dd826bec64ff4aabd8ce71ccef6da02d7d4" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" -"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" +"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" -"checksum mime_guess 1.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4c0961143b8efdcfa29c3ae63281601b446a4a668165454b6c90f8024954c5" +"checksum mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0d977de9ee851a0b16e932979515c0f3da82403183879811bc97d50bd9cc50f7" +"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" +"checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" "checksum modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58" -"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum phf 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "cec29da322b242f4c3098852c77a0ca261c9c01b806cae85a5572a1eb94db9a6" -"checksum phf_codegen 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "7d187f00cd98d5afbcd8898f6cf181743a449162aeb329dcd2f3849009e605ad" -"checksum phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "03dc191feb9b08b0dc1330d6549b795b9d81aec19efe6b4a45aec8d4caee0c4b" -"checksum phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "b539898d22d4273ded07f64a05737649dc69095d92cb87c7097ec68e3f150b93" +"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" +"checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" +"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" +"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum playground-middleware 0.1.0 (git+https://github.com/integer32llc/playground-middleware.git)" = "" "checksum plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a6a0dc3910bc8db877ffed8e457763b317cf880df4ae19109b9f77d277cf6e0" -"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" -"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" -"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" -"checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d" -"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +"checksum proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "175a40b9cf564ce9bf050654633dbf339978706b8ead1a907bb970b63185dd95" +"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" +"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" +"checksum safemem 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b08423011dae9a5ca23f07cf57dac3857f5c885d352b76f6d95f4aea9434d0" +"checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" +"checksum serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "cb4dc18c61206b08dc98216c98faa0232f4337e1e1b8574551d5bad29ea1b425" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" -"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" -"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" +"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" +"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" +"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25" +"checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "dcddca308b16cd93c2b67b126c688e5467e4ef2e28200dc7dfe4ae284f2faefc" +"checksum wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "f805d9328b5fc7e5c6399960fd1889271b9b58ae17bdb2417472156cc9fafdd0" +"checksum wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff88201a482abfc63921621f6cb18eb1efd74f136b05e5841e7f8ca434539e9" +"checksum wasm-bindgen-macro-support 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "6a433d89ecdb9f77d46fcf00c8cf9f3467b7de9954d8710c175f61e2e245bb0e" +"checksum wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "d41fc1bc3570cdf8d108c15e014045fd45a95bb5eb36605f96a90461fc34027d" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" diff --git a/Cargo.toml b/Cargo.toml index e986f2f..bbc1dae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,18 @@ [package] -name = "rust-web-server" -version = "1.0.0" -authors = ["José Quintana "] +name = "static-web-server" +version = "1.0.0-beta.1" +authors = ["Jose Quintana "] [dependencies] iron = ">= 0.5, < 0.7" -env_logger = "0.3.5" +log = "0.4" +chrono = "0.4" +env_logger = "0.5" playground-middleware = { git = "https://github.com/integer32llc/playground-middleware.git" } +envy = "0.3" +serde = "1.0" +serde_derive = "1.0" +flate2 = "1.0" [profile.release] lto = true diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 17a0325..0000000 --- a/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM scratch - -LABEL maintainer=https://github.com/joseluisq - -ADD bin / -ADD public /public - -ENTRYPOINT ["/rust-web-server"] diff --git a/Makefile b/Makefile index 21f0b47..083243d 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,122 @@ -DOCKER_IMG=cs-server-rust:latest -PLATFORM=x86_64-unknown-linux-musl +PKG_TARGET=x86_64-unknown-linux-musl +PKG_BIN_PATH=./bin -start: - -cargo run +PKG_NAME=$(shell cat Cargo.toml | sed -n 's/name = "\([^}]*\)"/\1/p') +PKG_TAG=$(shell cat Cargo.toml | sed -n 's/version = "\([^}]*\)"/\1/p') -check: - -cargo check -build: - -cargo build +####################################### +############# Development ############# +####################################### -release: - -cargo build --release --target $(PLATFORM) - -cp -rf target/$(PLATFORM)/release/rust-web-server ./bin - -strip ./bin/rust-web-server +install: + @rustup target add $(PKG_TARGET) + @cargo install --force cargo-make + @cargo install cargo-audit +.PHONY: install -exec: - ./target/release/rust-web-server +run: + @cargo make --makefile Tasks.Dev.toml run +.PHONY: run -img: - -docker build -t $(DOCKER_IMG) . -.PHONY: img +watch: + @cargo make --makefile Tasks.Dev.toml watch +.PHONY: watch + + +####################################### +########### Utility tasks ############# +####################################### test: - -echo "GET $(URL)" \ - | vegeta -cpus=12 attack \ - -workers=10 -duration=60s -connections=10000 -rate=200 -http2=false \ - | tee results.bin | vegeta report - -cat results.bin | vegeta report -reporter=plot > plot.html + @cargo test +.PHONY: test + +docker.image.alpine: + @docker build \ + --rm=true -f ./docker/alpine/Dockerfile \ + --build-arg SERVER_VERSION="alpine" -t ${PKG_NAME}:alpine . --pull=true +.PHONY: docker.image.alpine + + +####################################### +########## Production tasks ########### +####################################### + +# Compile release binary +define build_release = + set -e + set -u + + sudo chown -R rust:rust ./ + cargo build --release --target $(PKG_TARGET) + echo "Release build completed!" +endef + +# Shrink a release binary size +define build_release_shrink = + set -e + set -u + + mkdir -p $(PKG_BIN_PATH) + cp -rf ./target/$(PKG_TARGET)/release/$(PKG_NAME) $(PKG_BIN_PATH) + echo "Size before:" + du -sh $(PKG_BIN_PATH)/$(PKG_NAME) + strip $(PKG_BIN_PATH)/$(PKG_NAME) + echo "Size after:" + du -sh $(PKG_BIN_PATH)/$(PKG_NAME) + echo "Release size shrinking completed!" +endef + +# Creates release files (tarballs, zipballs) +define build_release_files = + set -e + set -u + + cd $(PKG_BIN_PATH) && \ + tar -czvf $(PKG_NAME)-v$(PKG_TAG)-x86_64-$(PKG_TARGET).tar.gz $(PKG_NAME) + du -sh ./* + echo "Release tarball/zipball files created!" +endef + +# Update docker files to latest tag per platform +define release_dockerfiles = + ./scripts/version.sh $(PKG_TAG) +endef + +prod.release: + set -e + set -u + + $(build_release) + $(build_release_shrink) + $(build_release_files) +.ONESHELL: prod.release + +prod.release.build: + @$(build_release) +.ONESHELL: prod.release.build + +prod.release.shrink: + @$(build_release_shrink) +.ONESHELL: prod.release.shrink + +prod.release.files: + @$(build_release_files) +.ONESHELL: prod.release.files + +prod.release.tag: + git tag -d latest + git push --delete origin latest + @$(release_dockerfiles) + git add . + git commit . -m "$(PKG_TAG)" + git tag latest + git tag $(PKG_TAG) + git push + git push origin --tags +.ONESHELL: prod.release.tag -.PHONY: start build check release exec test +prod.release.dockerfiles: + @$(release_dockerfiles) +.ONESHELL: prod.release.dockerfiles diff --git a/README.md b/README.md new file mode 100644 index 0000000..59e9cc5 --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +# Static Web Server [![Build Status](https://ci.joseluisq.net/api/badges/joseluisq/static-web-server/status.svg?branch=develop)](https://ci.joseluisq.net/joseluisq/static-web-server) [![](https://images.microbadger.com/badges/image/joseluisq/static-web-server.svg)](https://microbadger.com/images/joseluisq/static-web-server "Get your own image badge on microbadger.com") [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/joseluisq/static-web-server.svg)] + +> A fast web server to static files-serving powered by [Rust Iron](https://github.com/iron/iron). :zap: + +**Static Web Server** is an small (`1,6M` static binary) and fast web server to serving static files. Which is also suitable to deploy it into a Docker container. + +__Status:__ The status is WIP so feel free to contribute. + +## Usage + +Server is configurated via environment variables: + +- **SERVER_NAME**: Name for server. Default `nameless`. +- **SERVER_HOST**: Host address (E.g 127.0.0.1). Default `[::]`. +- **SERVER_PORT**: Host port. Default `80`. +- **SERVER_ROOT**: Root directory path of static files. Default `/public`. +- **SERVER_ASSETS**: Assets directory path for add cache headers functionality. Default `/public/assets`. + +## Docker stack + +Example using Traefik proxy + +```yaml +version: "3.3" + +services: + web: + image: joseluisq/static-web-server:latest + environment: + - SERVER_NAME=my-server + - SERVER_HOST=127.0.0.1 + - SERVER_PORT=8080 + - SERVER_ROOT=/html + - SERVER_ASSETS=./assets + volumes: + - ./some-dir-path:/html + labels: + - "traefik.enable=true" + - "traefik.frontend.entryPoints=https" + - "traefik.backend=localhost_dev" + - "traefik.frontend.rule=Host:localhost.dev" + - "traefik.port=80" + networks: + - traefik_net + +networks: + traefik_net: + external: true +``` + +## Development + +```sh +~> make help + +Static Web Server +Web Server to static files-serving. + +Please use `make ` where is one of: + install to install dependencies. + run to run server in development. + watch to run server (watch files mode) in development. + release to build a release. + docker_image to build a Docker image. +``` + +## Contributions + +Feel free to send some [Pull request](https://github.com/joseluisq/static-web-server/pulls) or [issue](https://github.com/joseluisq/static-web-server/issues). + +## License +MIT license + +© 2019 [Jose Quintana](https://git.io/joseluisq) diff --git a/Tasks.Dev.toml b/Tasks.Dev.toml new file mode 100644 index 0000000..c2de9da --- /dev/null +++ b/Tasks.Dev.toml @@ -0,0 +1,17 @@ +[env] +E_ARGS = "" +E_URL = "https://joseluisq.net" + +[tasks.watch] +command = "cargo" +args = ["watch", "-cx", "run -- ${E_ARGS}"] + +[tasks.run] +command = "cargo" +args = ["run", "run -- ${E_ARGS}"] + +[tasks.loadtest] +script = [ + "echo GET $E_URL | vegeta -cpus=12 attack -workers=10 -duration=60s -connections=10000 -rate=200 -http2=true | tee results.bin | vegeta report", + "cat results.bin | vegeta report -reporter=plot > plot.html" +] diff --git a/Tasks.Prod.toml b/Tasks.Prod.toml new file mode 100644 index 0000000..fe0a82b --- /dev/null +++ b/Tasks.Prod.toml @@ -0,0 +1,53 @@ +[env] +PKG_PLATFORM = "x86_64-unknown-linux-musl" +PKG_NAME = { script = ["cat Cargo.toml | awk 'match($0, /name = \"(.*)\"/, v) {print v[1]}'"] } +PKG_VERSION = { script = ["cat Cargo.toml | awk 'match($0, /version = \"([0-9.].+)\"/, v) {print v[1]}'"] } +PKG_BIN_DIR = "./bin" +PKG_BIN_PATH = "${PKG_BIN_DIR}/${PKG_NAME}" + +[tasks.clean_artifacts] +command = "cargo" +args = ["clean"] + +[tasks.clean_bin] +script = ["rm -rf bin"] + +[tasks.clean] +dependencies = [ + "clean_artifacts", + "clean_bin" +] + +[tasks.test] +command = "cargo" +args = ["test"] +dependencies = ["clean"] + +[tasks.mkdir] +script = ["mkdir -p ${PKG_BIN_DIR}"] + +[tasks.copy] +script = ["cp -rf target/${PKG_PLATFORM}/release/${PKG_NAME} ${PKG_BIN_DIR}"] + +[tasks.strip] +script = ["strip ${PKG_BIN_PATH}"] + +[tasks.size] +script = ["du -sh ${PKG_BIN_PATH}"] + +[tasks.build] +command = "cargo" +args = ["build", "--release", "--target", "${PKG_PLATFORM}"] + +[tasks.docker_image] +script = ["docker build -t ${PKG_NAME} -f ./docker/sws.dockerfile ."] + +[tasks.release] +dependencies = [ + "clean", + "build", + "mkdir", + "copy", + "strip", + "size" +] diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 29e8d96..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: '3' - -services: - cs-server: - image: cs-server-rust:latest - # build: - # context: . - # dockerfile: Dockerfile - deploy: - replicas: 1 - update_config: - parallelism: 1 - delay: 10s - restart_policy: - condition: on-failure - resources: - limits: - cpus: '0.5' - memory: 50M - reservations: - cpus: '0.5' - memory: 50M - ports: - - "8015:8015" - networks: - - overlay - -networks: - overlay: diff --git a/docker/alpine/Dockerfile.tmpl b/docker/alpine/Dockerfile.tmpl new file mode 100644 index 0000000..9d5a132 --- /dev/null +++ b/docker/alpine/Dockerfile.tmpl @@ -0,0 +1,26 @@ +FROM alpine:$ALPINE_VERSION + +LABEL maintainer="Jose Quintana " + +RUN apk --no-cache add ca-certificates tzdata +RUN set -ex; \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + armhf) arch='armv6' ;; \ + aarch64) arch='arm64' ;; \ + x86_64) arch='amd64' ;; \ + *) echo >&2 "error: unsupported architecture: $apkArch"; exit 1 ;; \ + esac; + +COPY ./bin/static-web-server /usr/local/bin/ +COPY ./public /public +EXPOSE 80 +CMD ["static-web-server"] + +# Metadata +LABEL org.opencontainers.image.vendor="Jose Quintana" \ + org.opencontainers.image.url="https://git.joseluisq.net/joseluisq/static-web-server" \ + org.opencontainers.image.title="Static Web Server" \ + org.opencontainers.image.description="A blazing fast web server to static files-serving powered by Rust." \ + org.opencontainers.image.version="$VERSION" \ + org.opencontainers.image.documentation="https://git.joseluisq.net/joseluisq/static-web-server" diff --git a/docker/envoy/.dockerignore b/docker/envoy/.dockerignore new file mode 100644 index 0000000..e1acb5a --- /dev/null +++ b/docker/envoy/.dockerignore @@ -0,0 +1,9 @@ +*.~ +.git +**/*.gz +**/*.log +**/*.tar +**/.DS_Store +.gitignore +*docker-compose* +Makefile diff --git a/docker/envoy/docker-compose.yml b/docker/envoy/docker-compose.yml new file mode 100644 index 0000000..35e2160 --- /dev/null +++ b/docker/envoy/docker-compose.yml @@ -0,0 +1,36 @@ +version: "3.3" + +services: + + service1: + image: static-web-server:latest + environment: + - SERVER_HOST=127.0.0.1 + - SERVER_PORT=8080 + - SERVER_NAME=Server-1 + - SERVICE_NAME=service1 + + # configs: + # - source: docker_registry_service + # target: /etc/envoy-service.yaml + volumes: + - ./envoy-service.yaml:/etc/envoy-service.yaml + deploy: + replicas: 1 + update_config: + parallelism: 1 + restart_policy: + condition: on-failure + networks: + envoymesh: + aliases: + - service1 + +#configs: +# docker_registry_service: +# external: true + +networks: + envoymesh: + external: + name: envoymesh diff --git a/docker/envoy/docker-entrypoint.sh b/docker/envoy/docker-entrypoint.sh new file mode 100644 index 0000000..9780215 --- /dev/null +++ b/docker/envoy/docker-entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -e + +/bin/static-web-server & +/usr/local/bin/envoy -c /etc/envoy-service.yaml --service-cluster ${SERVICE_NAME} diff --git a/docker/envoy/sw.envoy.dockerfile b/docker/envoy/sw.envoy.dockerfile new file mode 100644 index 0000000..9819d6a --- /dev/null +++ b/docker/envoy/sw.envoy.dockerfile @@ -0,0 +1,15 @@ +FROM envoyproxy/envoy-alpine:36f39c746eb7d03b762099b206403935b11972d8 + +LABEL maintainer=https://git.io/joseluisq + +RUN set -ex \ + && apk update && apk add --no-cache bash ca-certificates + +ADD bin /bin +ADD public /public +ADD docker/docker-entrypoint.sh /entrypoint.sh + +RUN chmod u+x /bin/static-web-server \ + && chmod u+x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/scratch/Dockerfile.tmpl b/docker/scratch/Dockerfile.tmpl new file mode 100644 index 0000000..9a9c646 --- /dev/null +++ b/docker/scratch/Dockerfile.tmpl @@ -0,0 +1,18 @@ +FROM scratch + +LABEL maintainer="Jose Quintana " + +COPY ./bin/static-web-server / +COPY ./public /public + +EXPOSE 80 +VOLUME ["/public"] +ENTRYPOINT ["/static-web-server"] + +# Metadata +LABEL org.opencontainers.image.vendor="Jose Quintana" \ + org.opencontainers.image.url="https://git.joseluisq.net/joseluisq/static-web-server" \ + org.opencontainers.image.title="Static Web Server" \ + org.opencontainers.image.description="A blazing fast web server to static files-serving powered by Rust." \ + org.opencontainers.image.version="$VERSION" \ + org.opencontainers.image.documentation="https://git.joseluisq.net/joseluisq/static-web-server" diff --git a/public/assets/favicon.ico b/public/assets/favicon.ico new file mode 100644 index 0000000..b8ad237 Binary files /dev/null and b/public/assets/favicon.ico differ diff --git a/public/assets/main.css b/public/assets/main.css new file mode 100644 index 0000000..85f066a --- /dev/null +++ b/public/assets/main.css @@ -0,0 +1,5 @@ +body { + font-family: Arial, Helvetica, sans-serif; + color: slategray; + text-align: center; +} diff --git a/public/index.html b/public/index.html index 455a52a..c7c3fc9 100644 --- a/public/index.html +++ b/public/index.html @@ -1,13 +1,19 @@ - + + - Example page + + + + My awesome static web page! + + -

Hello world

+

My awesome static web page!

- + diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..a9a4a2a --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e +set -u + +LATEST_TAG=$1 +BASE_PATH="$(pwd)/docker" + +if [ $# -eq 0 ]; then + echo "Usage: ./version.sh " + exit +fi + +export VERSION=$LATEST_TAG +export ALPINE_VERSION=3.10 + +PLATFORMS=( + "alpine" + "scratch" +) + +for PLATFORM in "${PLATFORMS[@]}"; do + PLATFORM_DIR="${BASE_PATH}/${PLATFORM}" + + if [ ! -d "$PLATFORM_DIR" ]; then + echo "Directory no found for \"${PLATFORM_DIR}\"" + exit 1 + fi + + echo "Generating Dockerfile for platform \"${PLATFORM}\"" + + rm -rf "${PLATFORM_DIR}/Dockerfile" + + envsubst \$ALPINE_VERSION,\$VERSION <"${PLATFORM_DIR}/Dockerfile.tmpl" >"${PLATFORM_DIR}/Dockerfile" +done + +echo "All Dockerfiles were updated!" diff --git a/src/env.rs b/src/env.rs new file mode 100644 index 0000000..5e582ca --- /dev/null +++ b/src/env.rs @@ -0,0 +1,33 @@ +#[derive(Deserialize, Debug)] +pub struct Config { + #[serde(default = "default_name")] + pub name: String, + #[serde(default = "default_host")] + pub host: String, + #[serde(default = "default_port")] + pub port: u16, + #[serde(default = "default_root")] + pub root: String, + #[serde(default = "default_assets")] + pub assets: String, +} + +pub fn default_name() -> String { + "nameless".to_string() +} + +pub fn default_host() -> String { + "[::]".to_string() +} + +pub fn default_port() -> u16 { + 80 +} + +pub fn default_root() -> String { + "./public".to_string() +} + +pub fn default_assets() -> String { + "./assets".to_string() +} diff --git a/src/gzip.rs b/src/gzip.rs new file mode 100644 index 0000000..c810310 --- /dev/null +++ b/src/gzip.rs @@ -0,0 +1,26 @@ +use flate2::write::GzEncoder; +use flate2::Compression; +use iron::headers::{ContentEncoding, Encoding}; +use iron::prelude::*; +use iron::AfterMiddleware; + +pub struct GzipMiddleware; + +impl AfterMiddleware for GzipMiddleware { + fn after(&self, _: &mut Request, mut resp: Response) -> IronResult { + let compressed_bytes = resp.body.as_mut().map(|b| { + let mut encoder = GzEncoder::new(Vec::new(), Compression::fast()); + { + let _ = b.write_body(&mut encoder); + } + encoder.finish().unwrap() + }); + + if let Some(b) = compressed_bytes { + resp.headers.set(ContentEncoding(vec![Encoding::Gzip])); + resp.set_mut(b); + } + + Ok(resp) + } +} diff --git a/src/logger.rs b/src/logger.rs new file mode 100644 index 0000000..707544a --- /dev/null +++ b/src/logger.rs @@ -0,0 +1,24 @@ +use iron::prelude::*; +use iron::AfterMiddleware; + +pub struct Logger; + +impl AfterMiddleware for Logger { + fn after(&self, req: &mut Request, res: Response) -> IronResult { + info!( + "Request [{}] {} - {}", + req.method, + res.status + .into_iter() + .map(|i| i.to_string()) + .collect::(), + req.url + .path() + .into_iter() + .map(|i| format!("/{}", i)) + .collect::() + ); + + Ok(res) + } +} diff --git a/src/main.rs b/src/main.rs index cc7f9b9..07c353e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,61 @@ +#[macro_use] +extern crate log; +#[macro_use] +extern crate serde_derive; + +extern crate chrono; extern crate env_logger; +extern crate envy; +extern crate flate2; extern crate iron; extern crate playground_middleware; +extern crate serde; +use chrono::Local; +use env_logger::Builder; use iron::prelude::*; +use log::LevelFilter; use playground_middleware::{Cache, GuessContentType, ModifyWith, Prefix, Staticfile}; +use std::io::Write; use std::time::Duration; -const ADDRESS: &'static str = "[::]:8015"; +#[macro_use] +mod gzip; +mod env; +mod logger; + +use crate::env::Config; +use crate::gzip::GzipMiddleware; +use crate::logger::Logger; fn main() { - env_logger::init().expect("Unable to initialize logger"); + Builder::new() + .format(|buf, record| { + writeln!( + buf, + "{} [{}] - {}", + Local::now().format("%Y-%m-%dT%H:%M:%S"), + record.level(), + record.args() + ) + }) + .filter(None, LevelFilter::Info) + .init(); + + let config = envy::prefixed("SERVER_") + .from_env::() + .expect("Unable to parsing config from env"); - let files = Staticfile::new("./public").expect("Directory to serve not found"); + // headers.append_raw("server", config.name.as_bytes().to_vec()); + + let _address = &format!( + "{}{}{}", + config.host.to_string(), + ":", + config.port.to_string() + ); + + let files = Staticfile::new(config.root).expect("Directory to serve not found"); let mut files = Chain::new(files); let one_day = Duration::new(60 * 60 * 24, 0); @@ -21,11 +65,14 @@ fn main() { .expect("Unable to create default content type"); files.link_after(ModifyWith::new(Cache::new(one_day))); - files.link_after(Prefix::new(&["assets"], Cache::new(one_year))); + files.link_after(Prefix::new(&[config.assets], Cache::new(one_year))); files.link_after(GuessContentType::new(default_content_type)); + files.link_after(GzipMiddleware); + files.link_after(Logger); let _server = Iron::new(files) - .http(ADDRESS) + .http(_address) .expect("Unable to start server"); - println!("Server listening at {}", ADDRESS); + + info!("HTTP Server `{}` is running on {}", config.name, _address); } -- libgit2 1.7.2