Skip to content

Instantly share code, notes, and snippets.

@swlkr
Created January 13, 2022 21:27
Show Gist options
  • Save swlkr/0ae9b7dfce4750125036ba70b4ab1b64 to your computer and use it in GitHub Desktop.
Save swlkr/0ae9b7dfce4750125036ba70b4ab1b64 to your computer and use it in GitHub Desktop.
Rails 7 dockerfile for shippers
FROM docker.io/library/ruby:3.0.3-slim
RUN apt-get update -qq && apt-get install -y --no-install-recommends curl build-essential git-core libjemalloc2 && rm -rf /var/lib/apt/lists/*
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
# install sqlite
RUN curl -O https://www.sqlite.org/2021/sqlite-autoconf-3370000.tar.gz && tar xvzf sqlite-autoconf-3370000.tar.gz
RUN cd sqlite-autoconf-3370000 && ./configure && make && make install
# install hiveminde for Procfile.dev support
RUN curl -O -L https://github.com/DarthSim/hivemind/releases/download/v1.1.0/hivemind-v1.1.0-linux-amd64.gz
RUN gunzip hivemind-v1.1.0-linux-amd64.gz && mv hivemind-v1.1.0-linux-amd64 bin/hivemind
# install nodejs and npm (for jsbundling_rails)
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get install -y --no-install-recommends nodejs && rm -rf /var/lib/apt/lists/*
RUN corepack enable
ARG USER=app
ARG GROUP=app
ARG UID=1101
ARG GID=1101
RUN groupadd --gid $GID $GROUP
RUN useradd --uid $UID --gid $GID --groups $GROUP -ms /bin/bash $USER
RUN mkdir -p /var/app
RUN chown -R $USER:$GROUP /var/app
USER $USER
WORKDIR /var/app
COPY --chown=$USER Gemfile* /var/app/
RUN bundle install
COPY --chown=$USER . /var/app
CMD ["rails", "server", "-b", "0.0.0.0"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment