diff --git a/Dockerfile b/Dockerfile index 9e236a8..10bb724 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,12 +19,17 @@ RUN bash -c "set -o pipefail && apt-get update \ && mkdir /node_modules && chown ruby:ruby -R /node_modules /app" USER ruby +ARG BUNDLE_WITHOUT='development test' +ENV BUNDLE_PATH=/usr/local/bundle COPY --chown=ruby:ruby Gemfile* ./ -RUN bundle install +RUN bundle config set without $BUNDLE_WITHOUT && \ + bundle config set deployment true && \ + bundle install +RUN mkdir .yarn public log tmp COPY --chown=ruby:ruby package.json *yarn* ./ -RUN yarn install +RUN yarn install --frozen-lockfile ARG RAILS_ENV="production" ARG NODE_ENV="production" @@ -36,7 +41,7 @@ ENV RAILS_ENV="${RAILS_ENV}" \ COPY --chown=ruby:ruby . . RUN if [ "${RAILS_ENV}" != "development" ]; then \ - SECRET_KEY_BASE_DUMMY=1 rails assets:precompile; fi + SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile; fi CMD ["bash"] @@ -51,8 +56,8 @@ ARG UID=1000 ARG GID=1000 RUN apt-get update \ - && apt-get install -y --no-install-recommends build-essential curl libpq-dev \ - && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ +&& apt-get install -y --no-install-recommends curl postgresql-client tzdata \ +&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ && apt-get clean \ && groupadd -g "${GID}" ruby \ && useradd --create-home --no-log-init -u "${UID}" -g "${GID}" ruby \ @@ -66,7 +71,8 @@ RUN chmod 0755 bin/* ARG RAILS_ENV="production" ENV RAILS_ENV="${RAILS_ENV}" \ PATH="${PATH}:/home/ruby/.local/bin" \ - USER="ruby" + USER="ruby" \ + BUNDLE_PATH=/usr/local/bundle COPY --chown=ruby:ruby --from=assets /usr/local/bundle /usr/local/bundle COPY --chown=ruby:ruby --from=assets /app/public /public @@ -76,4 +82,4 @@ ENTRYPOINT ["/app/bin/docker-entrypoint-web"] EXPOSE 8000 -CMD ["rails", "s"] +CMD ["rails", "s"] \ No newline at end of file