Skip to content

Commit

Permalink
add rust implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
arnehilmann committed Apr 23, 2021
1 parent 55659ba commit 82f7304
Show file tree
Hide file tree
Showing 10 changed files with 794 additions and 546 deletions.
319 changes: 168 additions & 151 deletions Cargo.lock

Large diffs are not rendered by default.

41 changes: 24 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
[package]
name = "markdeck"
version = "0.1.0"
version = "0.60.0"
authors = ["Arne Hilmann <arne@hilmann.de>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
grass = "0.10.4"
grass = "0"
anyhow = "1"

[dependencies]
rust-embed = { version = "5.8.0", features = ["compression"] }
grass = "0.10.4"
rusync = "0.7.0"
serde = { version = "1.0.124", features = ["derive"] }
serde_json = "1.0.64"
glob = "0.3.0"
rust-embed = { version = "5", features = ["compression"] }
grass = "0"
rusync = "0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
glob = "0"

actix = "0.10"
actix-codec = "0.3"
actix-codec = "0"
actix-web = "3"
actix-web-actors = "3"
actix-files = "0.3"
actix-files = "0"
awc = "2"
env_logger = "0.8"
futures = "0.3.1"
bytes = "0.5.3"
env_logger = "0"
futures = "0"
bytes = "0"
actix-service = "1"

notify = "4.0.15"
anyhow = "1.0"
ctrlc = { version = "3.1.8", features = ["termination"] }
uuid = { version = "0.8.2", features = ["serde", "v4"] }
notify = "4"
anyhow = "1"
ctrlc = { version = "3", features = ["termination"] }
uuid = { version = "0", features = ["serde", "v4"] }
log = "0"
walkdir = "2"
regex = "1"

clap = "2"
136 changes: 86 additions & 50 deletions src/Dockerfile.pandoc → Dockerfile.pandoc
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM alpine:3.12.2 AS ALPINE_BASE
FROM node:15.4.0-alpine3.12 AS NODE_BASE
FROM gradle:6.7.1-jdk8-openj9 AS GRADLE_BASE
FROM rust:1.48.0-alpine3.12 AS RUST_BASE
FROM alpine:3.13.4 AS alpine_base
FROM node:15.14.0-alpine3.13 AS node_base
FROM gradle:6.8.3-jdk8-openj9 AS gradle_base
# FROM rust:1.51.0-slim-buster AS rust_base
FROM rust:1.51.0-alpine3.13 AS rust_base


FROM GRADLE_BASE AS build-ditaa

FROM gradle_base AS build-ditaa

WORKDIR /
RUN curl -OL https://github.com/pepijnve/ditaa/archive/mini-0.12.tar.gz
Expand All @@ -16,17 +18,20 @@ RUN cp build/libs/ditaa*.jar /ditaa.jar



FROM NODE_BASE AS build-vega
FROM node_base AS build-vega

RUN apk add g++ make pkgconf pixman-dev cairo-dev pango-dev libjpeg-turbo-dev giflib-dev
RUN npm -g config set user root
RUN npm install -g vega vega-cli vega-lite \
&& npm cache clean --force
RUN tar zcvf vega.tgz /usr/local/bin/vl2* /usr/local/bin/vg2* /usr/local/lib/node_modules/vega*
RUN tar zcvf /vega.tgz /usr/local/bin/vl2* /usr/local/bin/vg2* /usr/local/lib/node_modules/vega*
RUN mkdir /vega
WORKDIR /vega
RUN tar zxvf /vega.tgz



FROM NODE_BASE AS build-mermaid
FROM node_base AS build-mermaid
ARG MERMAID_VERSION
WORKDIR /tmp
RUN yarn add mermaid@${MERMAID_VERSION}
Expand All @@ -35,7 +40,7 @@ RUN ls -al /



FROM RUST_BASE AS build-svgbob
FROM rust_base AS build-svgbob
ARG SVGBOB_VERSION
WORKDIR /tmp
RUN apk add curl musl-dev
Expand All @@ -51,7 +56,7 @@ RUN chmod a+rx /svgbob



FROM ALPINE_BASE AS build-githubstyle
FROM alpine_base AS build-githubstyle

WORKDIR /tmp
RUN apk add git
Expand All @@ -60,7 +65,7 @@ RUN cp pandoc-goodies/templates/html5/github/GitHub.html5 /



FROM ALPINE_BASE AS build-pandoc
FROM alpine_base AS build-pandoc
ARG PANDOC_VERSION
WORKDIR /tmp
RUN apk add curl
Expand All @@ -69,15 +74,15 @@ RUN mv bin/pandoc /



FROM ALPINE_BASE AS build-jquery
FROM alpine_base AS build-jquery
ARG JQUERY_VERSION
WORKDIR /tmp
RUN apk add curl
RUN curl -L -o /jquery.js https://code.jquery.com/jquery-${JQUERY_VERSION}.js



FROM ALPINE_BASE AS build-jqueryemojis
FROM alpine_base AS build-jqueryemojis
WORKDIR /tmp
RUN apk add curl
RUN curl -L -o emojis.zip https://github.com/rodrigopolo/jqueryemoji/archive/master.zip
Expand All @@ -87,7 +92,7 @@ RUN mv jqueryemoji-master/img/apple72/* /emojis



FROM ALPINE_BASE AS build-revealjs
FROM alpine_base AS build-revealjs
ARG REVEALJS_VERSION
WORKDIR /tmp
RUN apk add curl
Expand All @@ -99,7 +104,7 @@ RUN touch dist/reveal.esm.js.map



FROM ALPINE_BASE AS build-impressjs
FROM alpine_base AS build-impressjs
ARG IMPRESSJS_VERSION
WORKDIR /tmp
RUN apk add curl
Expand All @@ -110,15 +115,15 @@ RUN rm -rf *.md *.png build.js examples/ karma.conf.js package*.json qunit* test



FROM ALPINE_BASE AS build-plantuml
FROM alpine_base AS build-plantuml
WORKDIR /tmp
RUN apk add curl
# RUN curl -L -o /plantuml.jar "https://sourceforge.net/projects/plantuml/files/plantuml.jar/download?use_mirror=10gbps-io"
RUN curl -L -o /plantuml.jar "https://sourceforge.net/projects/plantuml/files/plantuml.jar/download"



FROM ALPINE_BASE AS build-asciinemaplayer
FROM alpine_base AS build-asciinemaplayer
ARG ASCIINEMAPLAYER_VERSION
WORKDIR /tmp
RUN apk add curl
Expand All @@ -128,7 +133,7 @@ RUN curl -L -o /asciinema-player.css "https://github.com/asciinema/asciinema-pla



FROM ALPINE_BASE AS build-foundationicons
FROM alpine_base AS build-foundationicons
WORKDIR /tmp
RUN apk add curl
RUN curl -L -O https://zurb.com/playground/uploads/upload/upload/288/foundation-icons.zip
Expand All @@ -137,65 +142,96 @@ RUN mv foundation-icons /



FROM ALPINE_BASE AS build-cssgg
FROM alpine_base AS build-cssgg
RUN apk add curl
RUN curl -L -o /all-gg.css https://css.gg/css



FROM NODE_BASE AS production
FROM alpine_base as build-mathjaxjs
RUN apk add git
RUN git clone https://github.com/mathjax/MathJax.git mj-tmp
RUN mv mj-tmp/es5 /mathjax

LABEL maintainer="arne@hilmann.de"

RUN apk add \
make bash curl \
graphviz inotify-tools rsync \
libqrencode jq sassc zip openjdk8-jre \
python3 py3-pip fontconfig lua5.3 \
pixman cairo pango libjpeg-turbo giflib \
&& rm -rf /var/cache/apk/*

RUN npm -g config set user root
RUN npm install -g mathjax-pandoc-filter doctoc \
&& npm cache clean --force

COPY --from=build-vega /vega.tgz /
WORKDIR /
RUN tar zxf vega.tgz
FROM rust_base as build-markdeck

RUN mkdir -p /usr/local/share/lua/5.3
RUN curl -o /usr/local/share/lua/5.3/inspect.lua -L https://raw.githubusercontent.com/kikito/inspect.lua/master/inspect.lua

RUN pip3 install MarkdownPP
RUN apk add musl-dev

RUN mkdir -p /markdeck/
COPY --from=build-pandoc /pandoc /usr/bin/
# TODO dont use docroot/main here, but copy from src/markdeck:
# COPY markdeck/ /markdeck/
COPY --from=build-revealjs /reveal.js /markdeck/assets/framework/reveal.js/
COPY --from=build-impressjs /impress.js /markdeck/assets/framework/impress.js/
COPY --from=build-jquery /jquery.js /markdeck/assets/3rdparty/
COPY --from=build-jqueryemojis /emojis /markdeck/lib/
COPY --from=build-ditaa /ditaa.jar /markdeck/lib/
COPY --from=build-mermaid /mermaid.min.js /mermaid.min.js.map /markdeck/assets/3rdparty/
COPY --from=build-asciinemaplayer /asciinema-player.* markdeck/assets/3rdparty/
# markdeck/assets/3rdparty/asciinema-player.js:
# markdeck/assets/3rdparty/asciinema-player.js.map:
COPY --from=build-asciinemaplayer /asciinema-player.js /asciinema-player.js.map /asciinema-player.css /markdeck/assets/3rdparty/
COPY --from=build-plantuml /plantuml.jar /markdeck/lib/
RUN ls -al /markdeck/assets/3rdparty
COPY --from=build-svgbob /svgbob* /usr/local/bin/
COPY --from=build-githubstyle /GitHub.html5 /markdeck/template-github.html
COPY --from=build-foundationicons /foundation-icons /markdeck/assets/markdeck/css
COPY --from=build-cssgg /all-gg.css /markdeck/assets/markdeck/css
COPY --from=build-mathjaxjs /mathjax /markdeck/assets/3rdparty/mathjax/
COPY src/markdeck/template* /markdeck/.markdeck/
COPY src/markdeck/explain.html /markdeck/
COPY src/markdeck/metadata.template /markdeck/.markdeck/
COPY src/markdeck/defaults.yaml /markdeck/.markdeck/
COPY src/markdeck/lib/*.lua /markdeck/.markdeck/
COPY src/markdeck/lib/*.config /markdeck/.markdeck/
COPY src/markdeck/lib/*.jar /markdeck/.markdeck/
COPY src/markdeck/assets/markdeck /markdeck/assets/

# TODO RUN rustup target add x86_64-unknown-linux-musl
# TODO RUN cargo install --target x86_64-unknown-linux-musl --path .

WORKDIR /sources
COPY Cargo.* build.rs ./
RUN mkdir src
RUN echo 'fn main() {}' > src/main.rs
RUN cargo build --release

COPY src ./src
RUN rm -rf src/docroot/main/
RUN ln -sf /markdeck src/docroot/main
RUN cargo build --release --frozen


COPY markdeck/ /markdeck/

WORKDIR /markdeck/assets/framework/reveal.js
RUN sassc css/theme/source/simple.scss > css/theme/simple.css
RUN sassc css/reveal.scss > css/reveal.css
FROM alpine_base AS production

LABEL maintainer="arne@hilmann.de"

RUN apk add \
bash curl \
graphviz \
libqrencode zip openjdk8-jre \
fontconfig lua5.3 \
pixman cairo pango libjpeg-turbo giflib \
npm \
&& rm -rf /var/cache/apk/*

WORKDIR /

RUN mkdir -p /usr/local/share/lua/5.3
RUN curl -o /usr/local/share/lua/5.3/inspect.lua -L https://raw.githubusercontent.com/kikito/inspect.lua/master/inspect.lua

COPY --from=build-vega /vega /
COPY --from=build-pandoc /pandoc /usr/bin/
COPY --from=build-svgbob /svgbob* /usr/local/bin/
COPY --from=build-markdeck /sources/target/release/markdeck /usr/bin/

# WORKDIR /markdeck/assets/framework/reveal.js
# RUN sassc css/theme/source/simple.scss > css/theme/simple.css
# RUN sassc css/reveal.scss > css/reveal.css

WORKDIR /markdeck
RUN ln -sf /target/assets/css/fonts /.fonts
RUN ln -sf /markdeck/assets/markdeck/css/fonts/ /usr/share/fonts

WORKDIR /source

ARG version
ENV VERSION $version

Expand All @@ -211,7 +247,7 @@ RUN chmod 755 /target
USER markdeck
VOLUME ["/source", "/target"]

ENTRYPOINT ["/markdeck/loop"]
ENTRYPOINT ["/usr/bin/markdeck", "--port", "8080", "--source", "/source", "--target", "/target", "--watcher", "CompareReference"]


FROM production AS development
Expand Down
12 changes: 1 addition & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
use std::error::Error;
use std::fs;

fn main() -> Result<(), Box<dyn Error>> {
println!("compiling scss");
let sass = grass::from_path(
"src/markdeck/assets/markdeck/css/markdeck.revealjs.scss",
&grass::Options::default())?;
fs::write("src/markdeck/assets/markdeck/css/markdeck.revealjs.css", sass)?;
Ok(())
}
fn main() {}
Loading

0 comments on commit 82f7304

Please sign in to comment.