11ARG RUBY_VER="3.3"
22FROM ruby:$RUBY_VER-alpine AS build-env
33
4- ARG PACKAGES="git libxml2 libxslt build-base curl-dev libxml2-dev libxslt-dev zlib-dev tzdata libpq-dev"
4+ ARG PACKAGES="git libxml2 libxslt build-base curl-dev libxml2-dev libxslt-dev zlib-dev tzdata libpq-dev yaml-dev "
55
66RUN apk update && \
77 apk upgrade && \
88 apk add --update --no-cache $PACKAGES && \
99 cp /usr/share/zoneinfo/Australia/Sydney /etc/localtime && \
1010 echo "Australia/Sydney" > /etc/timezone
1111
12- ENV APP_DIR /app
12+ ENV APP_DIR= " /app"
1313RUN mkdir $APP_DIR
1414WORKDIR $APP_DIR
1515
@@ -19,9 +19,10 @@ COPY Gemfile* $APP_DIR/
1919RUN gem install bundler
2020RUN bundle config set without 'test:assets'
2121RUN bundle config set --local path 'vendor/bundle'
22+ RUN bundle config set --local without 'test development'
2223RUN bundle config --global frozen 1 \
2324 && bundle install -j4 --retry 3 \
24- && bundle binstubs puma --force \
25+ && bundle binstubs bundler puma --force \
2526 # Remove unneeded files (cached *.gem, *.o, *.c)
2627 && rm -rf vendor/bundle/ruby/3.3.0/cache/*.gem \
2728 && find vendor/bundle/ruby/3.3.0/gems/ -name "*.c" -delete \
@@ -35,36 +36,32 @@ RUN rm -rf /app/tmp/pids/ && rm -rf /app/spec
3536
3637FROM ruby:$RUBY_VER-alpine
3738
38- # Copy just the application to this new image
39- ENV APP_DIR /app
39+ # Copy the application and bundled gems
40+ ENV APP_DIR= " /app"
4041COPY --from=build-env $APP_DIR $APP_DIR
4142WORKDIR $APP_DIR
4243
4344ENV BUNDLE_APP_CONFIG="$APP_DIR/.bundle"
4445
45- # install packages
46- ARG PACKAGES="tzdata libxml2 libxslt libc6-compat libpq-dev"
46+ # Install runtime packages
47+ ARG PACKAGES="tzdata libxml2 libxslt libc6-compat libpq-dev yaml-dev "
4748RUN apk update \
4849 && apk upgrade \
4950 && apk add --update --no-cache $PACKAGES
5051
5152# Create a non-privileged user
52- # defaults are appuser:10001
5353ARG IMAGE_UID="10001"
5454ENV UID=$IMAGE_UID
5555ENV USER=appuser
5656
57- # See https://stackoverflow.com/a/55757473/12429735RUN
5857RUN adduser -D -g "" -h "/nonexistent" -s "/sbin/nologin" -H -u "${UID}" "${USER}"
5958RUN chown appuser:appuser -R /app/tmp
60-
61- # NOTE:: this should not be used, instead use `RAILS_MASTER_KEY` env var
6259RUN chown appuser:appuser -R /app/config/
63- RUN bundle binstubs bundler --force
60+ RUN chown appuser:appuser -R /app/vendor/ bundle # Ensure appuser owns the gems
6461
65- # Use an unprivileged user.
62+ # Use the unprivileged user
6663USER appuser:appuser
6764
6865EXPOSE 8080
69- HEALTHCHECK CMD wget --no-verbose -q --spider http://0.0.0.0:8080/auth/authority?health=true
70- ENTRYPOINT ./bin/puma -b tcp://0.0.0.0:8080
66+ HEALTHCHECK CMD [ " wget" , " --no-verbose" , "-q" , " --spider" , " http://0.0.0.0:8080/auth/authority?health=true" ]
67+ ENTRYPOINT [ " ./bin/puma" , "-b" , " tcp://0.0.0.0:8080" ]
0 commit comments