Open hason opened 4 years ago
"Libsass" is simple how to use than "pyScss". It is a very slow build image on 'alpine linux', but not large size(only 3.6 MB).
Dockerfile_without_libsass
:
FROM python:3.8-alpine
RUN pip install --no-cache-dir nltk==3.4.5 mkdocs mkdocs-material
Dockerfile_with_libsass
:
FROM python:3.8-alpine
RUN apk add --update --upgrade --no-cache --virtual .build-deps musl-dev g++ \
&& pip install --no-cache-dir nltk==3.4.5 mkdocs mkdocs-material libsass \
&& apk del .build-deps
note: newer
nltk
is require compileregex
.
Source Dockerfile | Created Image Size |
---|---|
Dockerfile_without_libsass |
99.4MB |
Dockerfile_with_libsass |
103MB |
If you build an image from alpine:latest
:
FROM alpine:latest
RUN apk add --update --upgrade --no-cache python3 py3-pip --virtual .build-deps python3-dev musl-dev g++ \
&& pip3 install --no-cache-dir libsass
then the file _sass.abi3.so
has 60 MB:
ncdu 1.14.2 ~ Use the arrow keys to navigate, press ? for help
--- /usr/lib/python3.8/site-packages -------------------------------------------------------
/..
58.5 MiB [##########] _sass.abi3.so
2.1 MiB [ ] /pip
1.4 MiB [ ] /chardet
1.3 MiB [ ] /distlib
What about to commit the compiled css files? See https://github.com/executablebooks/sphinx-book-theme/blob/master/.pre-commit-config.yaml#L34-L44 or https://github.com/pandas-dev/pydata-sphinx-theme/blob/master/.pre-commit-config.yaml
Wow!
Now, alpine has native libsass package.
FROM alpine:latest
RUN apk update && apk add --update --upgrade --no-cache libsass python3
RUN apk add --update --upgrade --no-cache --virtual .build-deps \
python3-dev py3-pip py3-wheel musl-dev g++ libsass-dev \
&& SYSTEM_SASS=1 pip install --no-cache-dir libsass \
&& apk del .build-deps
then
# du -sh /usr/lib/python3.8/site-packages/
408.0K /usr/lib/python3.8/site-packages/
# ls -lh /usr/lib/libsass.so.1* /usr/lib/python3.8/site-packages/
lrwxrwxrwx 1 root root 16 Oct 1 10:38 /usr/lib/libsass.so.1 -> libsass.so.1.0.0
-rwxr-xr-x 1 root root 2.0M May 2 06:29 /usr/lib/libsass.so.1.0.0
/usr/lib/python3.8/site-packages/:
total 208K
-rw-r--r-- 1 root root 119 Jul 20 23:11 README.txt
drwxr-xr-x 2 root root 123 Oct 1 10:39 __pycache__
-rwxr-xr-x 1 root root 101.7K Oct 1 10:39 _sass.abi3.so
drwxr-xr-x 2 root root 126 Oct 1 10:39 libsass-0.20.1.dist-info
-rw-r--r-- 1 root root 6.9K Oct 1 10:39 pysassc.py
-rw-r--r-- 1 root root 31.6K Oct 1 10:39 sass.py
-rw-r--r-- 1 root root 267 Oct 1 10:39 sassc.py
-rw-r--r-- 1 root root 53.8K Oct 1 10:39 sasstests.py
drwxr-xr-x 3 root root 115 Oct 1 10:39 sassutils
As future support, I think it would be better to be able to set the PDF-only styles with "Sass (Scss)" at "mkdocs build". And, PRs welcome!
I want to create a docker image based on alpine linux for sphinx and this awesome theme. Libsass package is too complicated, it must be compiled and it is too heavy (~60MB) also. Would it be possible to replace it with another written in pure python? For example https://github.com/Kronuz/pyScss?