Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (49 loc) · 2 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (49 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# syntax=docker/dockerfile:1
# Development image for the docs site.
#
# Gemfile.lock only lists x86_64-linux, so build on amd64 or run
# `bundle lock --add-platform aarch64-linux` first. Not Alpine: the locked
# sass-embedded, ffi and google-protobuf gems are glibc builds.
ARG RUBY_VERSION=3.4
ARG DEBIAN_RELEASE=trixie
FROM ruby:${RUBY_VERSION}-slim-${DEBIAN_RELEASE} AS base
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
TZ=UTC \
BUNDLE_PATH=/usr/local/bundle \
BUNDLE_JOBS=4 \
BUNDLE_RETRY=3
# git for jekyll-last-modified-at, which reads each file's last commit date.
# libcurl for html-proofer, which loads it through ffi. The name is the trixie
# one, older releases call it libcurl4.
RUN apt-get update \
&& apt-get install -y --no-install-recommends git libcurl4t64 \
&& rm -rf /var/lib/apt/lists/*
FROM base AS gems
# eventmachine and http_parser.rb have no precompiled gems
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential libssl-dev \
&& rm -rf /var/lib/apt/lists/*
ENV BUNDLE_FROZEN=true
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle install && rm -rf "${BUNDLE_PATH}"/cache
FROM base AS dev
# Pass --build-arg UID=$(id -u) so generated files match the host owner
ARG UID=1000
ARG GID=1000
RUN if ! getent group "${GID}" >/dev/null; then groupadd --gid "${GID}" jekyll; fi \
&& useradd --uid "${UID}" --gid "${GID}" --create-home --shell /bin/bash jekyll
# git refuses to read a repo it thinks someone else owns
RUN git config --system --add safe.directory /app
COPY --from=gems --chown=${UID}:${GID} ${BUNDLE_PATH} ${BUNDLE_PATH}
# WORKDIR would create these root-owned, and jekyll writes to them
RUN install -d -o "${UID}" -g "${GID}" /app /app/_site /app/src /app/src/.jekyll-cache
WORKDIR /app
COPY --chown=${UID}:${GID} . .
USER jekyll
# 4000 site, 35729 livereload
EXPOSE 4000 35729
# Also allows `docker run <image> jekyll build`
ENTRYPOINT ["bundle", "exec"]
CMD ["jekyll", "serve", "--host", "0.0.0.0", "--livereload", "--drafts"]