Skip to content

Commit 4e6ae75

Browse files
committed
chore(Dockerfile): fix build and warnings
1 parent 4127e56 commit 4e6ae75

File tree

3 files changed

+231
-244
lines changed

3 files changed

+231
-244
lines changed

Dockerfile

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
ARG RUBY_VER="3.3"
22
FROM 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

66
RUN 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"
1313
RUN mkdir $APP_DIR
1414
WORKDIR $APP_DIR
1515

@@ -19,9 +19,10 @@ COPY Gemfile* $APP_DIR/
1919
RUN gem install bundler
2020
RUN bundle config set without 'test:assets'
2121
RUN bundle config set --local path 'vendor/bundle'
22+
RUN bundle config set --local without 'test development'
2223
RUN 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

3637
FROM 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"
4041
COPY --from=build-env $APP_DIR $APP_DIR
4142
WORKDIR $APP_DIR
4243

4344
ENV 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"
4748
RUN apk update \
4849
&& apk upgrade \
4950
&& apk add --update --no-cache $PACKAGES
5051

5152
# Create a non-privileged user
52-
# defaults are appuser:10001
5353
ARG IMAGE_UID="10001"
5454
ENV UID=$IMAGE_UID
5555
ENV USER=appuser
5656

57-
# See https://stackoverflow.com/a/55757473/12429735RUN
5857
RUN adduser -D -g "" -h "/nonexistent" -s "/sbin/nologin" -H -u "${UID}" "${USER}"
5958
RUN chown appuser:appuser -R /app/tmp
60-
61-
# NOTE:: this should not be used, instead use `RAILS_MASTER_KEY` env var
6259
RUN 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
6663
USER appuser:appuser
6764

6865
EXPOSE 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"]

Gemfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ gem "opentelemetry-sdk"
4141
gem "opentelemetry-exporter-otlp"
4242
gem "opentelemetry-instrumentation-all"
4343

44-
# Runtime debugging
45-
gem "rbtrace"
46-
4744
# Fast JSON parsing
4845
gem "yajl-ruby"
4946
gem "multi_json"

0 commit comments

Comments
 (0)