-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
71 lines (55 loc) · 2.05 KB
/
Dockerfile
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
71
# Ruby image to use, change with [--build-arg RUBY_VERSION="3.3.0"]
ARG RUBY_VERSION="3.3.0"
# Alpine image to use, change with [--build-arg ALPINE_VERSION="3.19"]
ARG ALPINE_VERSION="3.19"
# s3deploy version to use
ARG S3DEPLOY_VERSION="2.11.0"
FROM ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION} AS dltj-jekyll-builder
# Install build dependencies
RUN set -eux; \
apk add --no-cache --virtual build-deps \
build-base \
zlib-dev \
git
# Install Bundler
RUN set -eux; gem install bundler
COPY Gemfile-docker ./Gemfile
ENV BUNDLE_HOME=/usr/local/bundle \
BUNDLE_APP_CONFIG=/usr/local/bundle \
BUNDLE_DISABLE_PLATFORM_WARNINGS=true \
BUNDLE_BIN=/usr/local/bundle/bin
# Install gems from `Gemfile` via Bundler
RUN set -eux; \
bundler install
FROM ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION} AS dltj-jekyll-runner
# Repeat ARG here because [Docker is stupid](https://docs.docker.com/reference/dockerfile/#understand-how-arg-and-from-interact)
ARG S3DEPLOY_VERSION
# `git` is needed by the last-modified-at plugin
# `nodejs` is needed by one of the gems
# `jemalloc` is the malloc replacement
RUN set -eux; \
apk add --no-cache --virtual runner-deps \
git \
nodejs \
jemalloc \
aws-cli \
curl \
jq
RUN set -eux; \
curl -s -S -L -f https://github.com/bep/s3deploy/releases/download/v${S3DEPLOY_VERSION}/s3deploy_${S3DEPLOY_VERSION}_linux-amd64.tar.gz -o /tmp/s3deploy.tar.gz; \
tar -xzf /tmp/s3deploy.tar.gz --directory /usr/local/bin s3deploy; \
rm /tmp/s3deploy.tar.gz
# Install jemalloc — see https://github.com/jemalloc/jemalloc/issues/1443#issuecomment-1895891270
RUN set -eux; \
apk add --no-cache patchelf; \
patchelf --add-needed libjemalloc.so.2 /usr/local/bin/ruby; \
apk del patchelf
ENV RUBY_YJIT_ENABLE=1 \
MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:500,muzzy_decay_ms:5000,narenas:2"
COPY --from=dltj-jekyll-builder /usr/local/bundle /usr/local/bundle
COPY --from=dltj-jekyll-builder /Gemfile* /
# Clean up
WORKDIR /srv/jekyll
EXPOSE 4000
ENTRYPOINT ["bundler", "exec", "jekyll"]
CMD ["--version"]