Last active
April 14, 2021 12:08
-
-
Save YasuhiroYoshida/25ff5f76a04734812178cc60fd784de0 to your computer and use it in GitHub Desktop.
Dockerfile for a Rails project with Ruby 2.7.1 with jemalloc built on Debian 10 (USER ≠ root)
This file contains hidden or 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
FROM debian:buster-slim | |
ARG RUBY_VERSION=2.7.1-jemalloc | |
# RUN with pipe recommendation: https://github.com/hadolint/hadolint/wiki/DL4006 | |
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | |
RUN apt-get update -q \ | |
&& apt-get dist-upgrade --assume-yes \ | |
&& apt-get install --assume-yes -q --no-install-recommends \ | |
curl \ | |
gnupg \ | |
apt-transport-https \ | |
ca-certificates \ | |
build-essential \ | |
zlib1g-dev \ | |
libpq-dev \ | |
libxml2-dev \ | |
libxslt-dev \ | |
pkg-config \ | |
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - \ | |
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ | |
&& apt update \ | |
&& apt install --assume-yes -q yarn \ | |
&& curl -SLf https://raw.githubusercontent.com/fullstaq-labs/fullstaq-ruby-server-edition/master/fullstaq-ruby.asc | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - \ | |
&& echo "deb https://apt.fullstaqruby.org debian-10 main" > /etc/apt/sources.list.d/fullstaq-ruby.list \ | |
&& apt-get update -q \ | |
&& apt-get install --assume-yes -q --no-install-recommends fullstaq-ruby-${RUBY_VERSION} \ | |
&& apt-get autoremove --assume-yes \ | |
&& rm -rf /var/lib/apt/lists \ | |
&& rm -fr /var/cache/apt \ | |
&& mkdir .bundle | |
ENV USER_NAME=app | |
ENV GROUP_NAME=$USER_NAME | |
ENV APP_HOME=/home/$USER_NAME | |
ENV GEM_HOME /usr/local/bundle | |
ENV BUNDLE_PATH="$GEM_HOME" \ | |
BUNDLE_SILENCE_ROOT_WARNING=1 \ | |
BUNDLE_APP_CONFIG="$GEM_HOME" \ | |
RUBY_VERSION=$RUBY_VERSION \ | |
LANG=C.UTF-8 LC_ALL=C.UTF-8 | |
RUN groupadd $GROUP_NAME | |
RUN useradd -g $GROUP_NAME -m $USER_NAME | |
Add . $APP_HOME | |
# path recommendation: https://github.com/bundler/bundler/pull/6469#issuecomment-383235438 | |
ENV PATH $GEM_HOME/bin:$BUNDLE_PATH/gems/bin:/usr/lib/fullstaq-ruby/versions/${RUBY_VERSION}/bin:$PATH | |
ENTRYPOINT ["/bin/bash", "/home/app/entrypoint.sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment