Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 58 additions & 19 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,68 @@
FROM mcr.microsoft.com/devcontainers/rust:bullseye
# Install fonts using fnt
FROM alpine:latest as fonts-fnt
# # Get git to clone repos and install fnt's dependencies: chafa
RUN apk add --no-cache git make curl bash

ARG TYPST_VERSION=v0.11.0
ARG NOTEBOOKiNATOR_VERSION=1.0.1
# fake otfinfo and chafa as they are only required by fnt for a few commands but are always checked
COPY <<EOF /usr/bin/otfinfo
#!/bin/sh
echo "otfinfo doesn't actually exist on this system and was faked in order to force necessary fnt features to work"
exit 10
EOF
COPY <<EOF /usr/bin/chafa
#!/bin/sh
echo "chafa doesn't actually exist on this system and was faked in order to force necessary fnt features to work"
exit 11
EOF
RUN chmod a+x /usr/bin/otfinfo /usr/bin/chafa

# Install Typst
RUN wget https://github.com/typst/typst/releases/download/${TYPST_VERSION}/typst-x86_64-unknown-linux-musl.tar.xz && \
tar -xvf typst-x86_64-unknown-linux-musl.tar.xz && \
mv typst-x86_64-unknown-linux-musl/typst /usr/local/bin/typst && \
rm -rf ./typst-x86_64-unknown-linux-musl*
# Download fnt
RUN git clone https://github.com/alexmyczko/fnt.git ./fnt
# Install and perform simple test
RUN cd ./fnt && make install && fnt
# Update fnt's known fonts
RUN fnt update

# Install typst-live
RUN cargo install typst-live
ENV PATH="/root/.cargo/bin:${PATH}"
# Install fonts
ARG FNT_FONTS
RUN echo "$FNT_FONTS" | tr ' ' '\n' | xargs -rP 4 -I {} fnt install {}
RUN mv /usr/local/share/fonts /fonts

# Install virgil font (excalidraw)
FROM alpine:latest as fonts-virgil
RUN apk add --no-cache woff2
# Download compressed font file
RUN wget https://virgil.excalidraw.com/Virgil.woff2 -O ./Virgil.woff2
# Decompress to Virgil.ttf
RUN woff2_decompress Virgil.woff2
RUN rm Virgil.woff2

# create add-entry binary
FROM rust:1-bullseye as add-entry-binary
COPY scripts scripts
RUN cargo install --root /usr/local/cargo/ --path ./scripts/add-entry

# create typst-live binary
FROM rust:1-bullseye as typst-live-binary

RUN cargo install --root /usr/local/cargo/ typst-live

# Create final product
FROM mcr.microsoft.com/devcontainers/rust:bullseye as final

# We need to change the user here because typst local packages are installed per user
USER vscode
WORKDIR /home/vscode/

# Install fonts
RUN wget https://github.com/google/fonts/raw/main/ofl/blinker/Blinker-Regular.ttf && \
wget https://github.com/google/fonts/raw/main/ofl/firasans/FiraSans-Regular.ttf && \
mkdir -p /home/vscode/.local/share/fonts/ && \
mv ./*.ttf /home/vscode/.local/share/fonts

ARG NOTEBOOKINATOR_VERSION=1.0.1
ARG NOTEBOOKINATOR_REPO=https://github.com/The-Notebookinator/notebookinator.git
# Install the notebookinator
RUN git clone --depth 1 --branch ${NOTEBOOKiNATOR_VERSION} https://github.com/The-Notebookinator/notebookinator.git && \
RUN git clone --depth 1 --branch ${NOTEBOOKINATOR_VERSION} ${NOTEBOOKINATOR_REPO} notebookinator && \
./notebookinator/scripts/package @local && \
rm -rf notebookinator
rm -rf notebookinator

# install fonts
COPY --from=fonts-fnt /fonts/* /usr/local/share/fonts/
COPY --from=fonts-virgil /Virgil.ttf /usr/local/share/fonts/
COPY --from=typst-live-binary /usr/local/cargo/bin/* /usr/local/cargo/bin/
COPY --from=add-entry-binary /usr/local/cargo/bin/* /usr/local/cargo/bin/
16 changes: 12 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
"build": {
"dockerfile": "Dockerfile",
"args": {
"TYPST_VERSION": "v0.11.0"
}
"FNT_FONTS": "carlito firasans blinker"
},
"context": ".."
},
"customizations": {
"vscode": {
"extensions": [
"nvarner.typst-lsp",
"mathematic.vscode-pdf"
"mathematic.vscode-pdf",
"pomdtr.excalidraw-editor"
]
}
},
"updateContentCommand": "./scripts/prepare.sh",
"features": {
"ghcr.io/michidk/devcontainers-features/typst:1": {
"version": "0.11.0"
}
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pdf
target
Loading