Skip to content

Instantly share code, notes, and snippets.

@ianjosephwilson
Last active November 25, 2024 22:00
Show Gist options
  • Save ianjosephwilson/193b97fc50de35147c07e1d966a499e2 to your computer and use it in GitHub Desktop.
Save ianjosephwilson/193b97fc50de35147c07e1d966a499e2 to your computer and use it in GitHub Desktop.
Dockerfile to run dart sass in a Docker container. Runs as user 100 in group 1000. I mount a "scss" volume to /app/frontend/scss and "bundles" volume to /app/frontend/bundles. Essentially input into output. To create a production bundle you can run the docker container with --style=compressed --no-source-map.
# This is based on the directions at https://github.com/sass/dart-sass?tab=readme-ov-file#in-docker on 11-04-2024.
# Dart stage
FROM bufbuild/buf AS buf
FROM dart:stable AS dart
ARG DART_SASS_VERSION=1.81.0
# Include Protocol Buffer binary
COPY --from=buf /usr/local/bin/buf /usr/local/bin/
ENV HOME=/dart-sass
ENV PUB_CACHE=/dart-sass/.pub-cache
RUN git clone --depth 1 --branch ${DART_SASS_VERSION} https://github.com/sass/dart-sass.git /dart-sass
RUN mkdir /dart-sass/.pub-cache
RUN chown -R 1000:100 /dart-sass
RUN mkdir -p /app /app/frontend /app/frontend/bundles/
RUN chown 1000:100 /app /app/frontend /app/frontend/bundles/
USER 1000:100
WORKDIR /dart-sass
RUN dart pub get
RUN dart run grinder protobuf
WORKDIR /app
COPY --chown=1000:100 ./frontend/scss /app/frontend/scss
ENTRYPOINT ["dart", "/dart-sass/bin/sass.dart", "/app/frontend/scss/:/app/frontend/bundles/"]
#Alt default to production with --style=compressed
CMD ["--watch"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment