Files
nairobi/Dockerfile
Javi Martín 8c5e7121ef Combine apt statements in Dockerfile
Quoting the Docker documentation [1]:

> Always combine RUN apt-get update with apt-get install in the same RUN
> statement.
> (...)
> Using apt-get update alone in a RUN statement causes caching issues
> and subsequent apt-get install instructions fail.
> (...)
> Docker sees the initial and modified instructions as identical and
> reuses the cache from previous steps. As a result the apt-get update
> is not executed because the build uses the cached version. Because the
> apt-get update is not run, your build can potentially get an outdated
> version of the curl and nginx packages.
>
> Using RUN apt-get update && apt-get install -y ensures your Dockerfile
> installs the latest package versions with no further coding or manual
> intervention.

[1] https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
2022-04-08 16:13:09 +02:00

41 lines
1.6 KiB
Docker

FROM ruby:2.7.4-buster
ENV DEBIAN_FRONTEND noninteractive
# Install essential Linux packages
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql-client nodejs imagemagick sudo libxss1 libappindicator1 libindicator7 unzip memcached cmake pkg-config shared-mime-info
# Install Chromium for E2E integration tests
RUN apt-get update -qq && apt-get install -y chromium
# Files created inside the container repect the ownership
RUN adduser --shell /bin/bash --disabled-password --gecos "" consul \
&& adduser consul sudo \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN echo 'Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bundle/bin"' > /etc/sudoers.d/secure_path
RUN chmod 0440 /etc/sudoers.d/secure_path
COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
# Define where our application will live inside the image
ENV RAILS_ROOT /var/www/consul
# Create application home. App server will need the pids dir so just create everything in one shot
RUN mkdir -p $RAILS_ROOT/tmp/pids
# Set our working directory inside the image
WORKDIR $RAILS_ROOT
# Use the Gemfiles as Docker cache markers. Always bundle before copying app src.
# (the src likely changed and we don't want to invalidate Docker's cache too early)
COPY Gemfile* ./
RUN bundle install
# Copy the Rails application into place
COPY . .
# Define the script we want run once the container boots
# Use the "exec" form of CMD so our script shuts down gracefully on SIGTERM (i.e. `docker stop`)
# CMD [ "config/containers/app_cmd.sh" ]
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]