惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
F
Fortinet All Blogs
The Register - Security
The Register - Security
雷峰网
雷峰网
博客园 - 【当耐特】
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements
S
Schneier on Security
Latest news
Latest news
S
Securelist
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
L
Lohrmann on Cybersecurity
V
Visual Studio Blog
NISL@THU
NISL@THU
Cyberwarzone
Cyberwarzone
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
Spread Privacy
Spread Privacy
酷 壳 – CoolShell
酷 壳 – CoolShell
Security Latest
Security Latest
A
About on SuperTechFans
大猫的无限游戏
大猫的无限游戏
SecWiki News
SecWiki News
N
News and Events Feed by Topic
T
Threatpost
The GitHub Blog
The GitHub Blog
博客园_首页
F
Full Disclosure
爱范儿
爱范儿
The Hacker News
The Hacker News
T
The Blog of Author Tim Ferriss
Stack Overflow Blog
Stack Overflow Blog
Last Week in AI
Last Week in AI
月光博客
月光博客
C
Check Point Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
博客园 - 司徒正美

John Bokma's Hacking and Hiking

Failed to verify signature archive-contents.sig in Emacs Aquamacs 3.6 Hangs When Saving An Encrypted File PAR trouble How To Create a Bootable LibreELEC Installation using Mac OS Running pdflatex Using the Alpine Pandoc LaTeX Docker Image Timezones in Alpine Docker Containers A Tale of Three Docker Images Debugging a Perl Docker container Perl Time::Piece Unicode Issue Giving Docker Desktop for macOS a Second Chance Flashing another TP-Link TL-WDR4300 with OpenWrt firmware Rehousing two tarantulas Getting started with the Perl version of tumblelog on Ubuntu 18.04 LTS A visit to Avonturia De Vogelkelder Flashing a TP-Link TL-WDR4300 with OpenWrt firmware Mounting a VDI File in a Different VirtualBox Guest Wireless Headless Raspberry Pi - John Bokma A Matter of Time - John Bokma Hand coding an RSS 2.0 feed in Python RFC #822 and RFC #3339 dates in Perl RFC #822 and RFC #3339 dates in Python Hand coding an RSS 2.0 feed in Perl Nav Element with no Heading Rewriting CommonMark Nodes in Perl "right" this time
A Docker Image for Sass
John Bokma · 2021-06-18 · via John Bokma's Hacking and Hiking

June 17, 2021

Edit: Please don't use this Dockerfile. Instead download sass.Dockerfile from my tumblelog project.

About two weeks ago I installed Docker Desktop for macOS on my Mac mini late 2014. Since then I have moved several programs to Docker images and am happy with the result. For example Plurrrr is now generated by tumblelog running inside a Docker container instead of a VirtualBox virtual machine running some version of Ubuntu.

I don't like to install all kinds of requirements on my main operating system hence why I use VirtualBox. I am now switching to Docker because I might upgrade to a Mac later this year with Apple Silicon. And because it's unclear to me if VirtualBox is going to run natively on the ARM processor I decided to try out Docker.

Containerizing Sass

One of the programs that I wanted to containerize is Sass. I use this program to generate the CSS for several of my sites. The problem with Sass is that there are many versions: Ruby Sass (no longer maintained), LibSass wrappers, Dart Sass, and a Node version of Sass. The later is compiled with dart2js. I decided to settle on the Node version as the official Dart Docker image is quite large.

So a few days ago I wrote the following Dockerfile:

# Syntax=docker/dockerfile:1
FROM alpine:latest

WORKDIR /app

RUN apk add --no-cache npm \
    && npm install --global sass

WORKDIR /data

ENTRYPOINT ["npx", "sass"]

This worked very well and resulted in an image of 59.7MB. But when I learned there was an official Node image I was wondering if using this image could result in a smaller image. So today I created the following Docker image:

# Syntax=docker/dockerfile:1
FROM node:alpine

WORKDIR /app

RUN npm install --global sass

WORKDIR /data

ENTRYPOINT ["npx", "sass"]

But this one resulted in an image of 120.57MB. I have no idea what extras are present in this image but since the smaller image works those extras don't seem necessary for Sass to work so I decided to stick with the smaller image.

Running the Container

Because I have a tumblelog directory with all styles located in a projects directory which is a sibling of my sites directory I want Docker to be able to access both directories without exposing too much to it:

in-house
   :
   `--- projects
   |       :
   |       `--- tumblelog
   |       :       :
   |               `--- styles
   |
   `--- sites
           :
           `--- plurrrr.com
           :       :
           :       `--- htdocs

So instead of one volume (in-house) I specified two volumes as follows when running docker inside the plurrrr.com directory:

docker run --rm \
       --volume "`pwd`/../../projects/tumblelog/styles:/data/styles:ro" \
       --volume "`pwd`/htdocs:/data/htdocs" \
       --user `id -u`:`id -g` node/sass --no-source-map --style compressed \
       styles/soothe.scss htdocs/soothe.css

The first --volume maps the styles directory on the host read only (ro) as /data/styles in the container. The second volume maps the htdocs directory as /data/htdocs in the container. Since /data is the current working directory inside the container I can specify styles/soothe.scss as the input file and htdocs/soothe.css as the output file.