-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
94 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,52 @@ | ||
# 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 | ||
# Use Python as the base image | ||
FROM python:3.12.7-slim | ||
|
||
# s3deploy version to use | ||
ARG S3DEPLOY_VERSION="2.12.1" | ||
|
||
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 | ||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# `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 \ | ||
# Install necessary system dependencies and PDM | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
nodejs \ | ||
jemalloc \ | ||
aws-cli \ | ||
curl \ | ||
jq | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
# Install PDM | ||
&& curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 - | ||
|
||
# Ensure /root/.local/bin is in PATH | ||
ENV PATH="/root/.local/bin:$PATH" | ||
|
||
# Get the `s3deploy` program | ||
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 | ||
# Copy the pyproject.toml and pdm.lock files | ||
COPY pyproject.toml pdm.lock* util /app/ | ||
|
||
# Install the dependencies | ||
RUN pdm install --prod --no-self | ||
|
||
# Clone the specified Pelican source repository | ||
RUN git clone https://github.com/dltj/pelican.git /app/pelican | ||
|
||
# Clone the specified theme repository | ||
RUN git clone https://github.com/dltj/pelican-hyde.git /app/pelican-themes/pelican-hyde | ||
|
||
ENV RUBY_YJIT_ENABLE=1 \ | ||
MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:500,muzzy_decay_ms:5000,narenas:2" | ||
# Install Pelican from the cloned source | ||
RUN pip install /app/pelican | ||
|
||
COPY --from=dltj-jekyll-builder /usr/local/bundle /usr/local/bundle | ||
COPY --from=dltj-jekyll-builder /Gemfile* / | ||
# Copy your Pelican configuration files to the container | ||
COPY pelicanconf.py /app/pelicanconf.py | ||
COPY publishconf.py /app/publishconf.py | ||
|
||
# Clean up | ||
WORKDIR /srv/jekyll | ||
# Expose port 8000 for serving | ||
EXPOSE 8000 | ||
|
||
EXPOSE 4000 | ||
ENTRYPOINT ["bundler", "exec", "jekyll"] | ||
CMD ["--version"] | ||
# Let's get into it! | ||
ENTRYPOINT ["pdm", "run", "pelican"] | ||
CMD ["--version"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.