2024-04-23 22:33:08 +00:00
|
|
|
# Pull base image from official repo
|
|
|
|
FROM rubylang/ruby:3.3.0-jammy
|
|
|
|
|
|
|
|
# Install some required packages for building Gems
|
|
|
|
RUN INSTALL_PKGS="gcc g++ libyaml-dev make nodejs" && \
|
|
|
|
apt-get -q clean && \
|
|
|
|
apt-get -q update && \
|
|
|
|
apt-get install -y $INSTALL_PKGS && \
|
|
|
|
apt-get -q clean
|
|
|
|
|
|
|
|
# Parameters for default user:group
|
|
|
|
ARG uid=1000
|
2024-05-23 09:34:47 +00:00
|
|
|
ARG user=appuser
|
2024-04-23 22:33:08 +00:00
|
|
|
ARG gid=1000
|
2024-05-23 09:34:47 +00:00
|
|
|
ARG group=appgroup
|
2024-04-23 22:33:08 +00:00
|
|
|
|
2024-05-23 09:21:02 +00:00
|
|
|
# Ensure desired user and group for build and runtime (convenient)
|
|
|
|
RUN userdel --force --remove $(getent passwd ${uid} | cut -d: -f1) || true; \
|
|
|
|
groupdel $(getent group ${gid} | cut -d: -f1) || true; \
|
|
|
|
groupadd -g "${gid}" "${group}" && \
|
|
|
|
useradd -md /home/${user} -s /bin/bash -g "${group}" -u "${uid}" "${user}";
|
2024-04-23 22:33:08 +00:00
|
|
|
|
|
|
|
# Copy requirements in non-root user home directory
|
|
|
|
COPY Gemfile Gemfile.lock "/home/${user}/"
|
|
|
|
RUN chown "${user}:${group}" "/home/${user}/Gemfile"*
|
|
|
|
|
|
|
|
# Switch to non-root user
|
|
|
|
USER ${user}
|
2024-05-23 09:56:49 +00:00
|
|
|
WORKDIR /appdata
|
2024-04-23 22:33:08 +00:00
|
|
|
|
|
|
|
# Install required gems
|
|
|
|
RUN echo "gem: --no-document --user-install --bindir /home/${user}/bin" >> /home/${user}/.gemrc && \
|
2024-05-23 09:56:49 +00:00
|
|
|
echo "gempath: /home/${user}/.gem/ruby:/home/${user}/.bundle/gems/ruby/3.3.0" >> /home/${user}/.gemrc && \
|
|
|
|
gem install bundler --version `sed -n -r -e '/BUNDLED WITH/,$ { s/\s+([.0-9]+)/\1/ p }' /home/${user}/Gemfile.lock` && \
|
2024-04-23 22:33:08 +00:00
|
|
|
bundle config --global path /home/${user}/.bundle/gems && \
|
|
|
|
bundle config --global bin /home/${user}/bin && \
|
2024-05-23 09:56:49 +00:00
|
|
|
bundle install --gemfile=/home/${user}/Gemfile && \
|
2024-04-23 22:33:08 +00:00
|
|
|
rm -rf /home/${user}/.bundle/cache
|
|
|
|
|
|
|
|
ENV PATH=/home/${user}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
|
2024-05-22 12:30:15 +00:00
|
|
|
ENTRYPOINT ["jekyll"]
|
|
|
|
CMD ["server", "--verbose", "--host", "0.0.0.0", "--incremental"]
|