Skip to content

Commit

Permalink
trunk check is clean
Browse files Browse the repository at this point in the history
  • Loading branch information
daveio committed Feb 26, 2025
1 parent 44b76d7 commit 1dfac82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WORKDIR /rails

# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
apt-get install --no-install-recommends -y curl=7.88.1-10+deb12u5 libjemalloc2=5.3.0-1 libvips=8.14.2-1 sqlite3=3.40.1-2 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Set production environment
Expand All @@ -30,7 +30,7 @@ FROM base AS build

# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git pkg-config && \
apt-get install --no-install-recommends -y build-essential=12.9 git=1:2.39.2-1.1 pkg-config=1.8.1-1 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install application gems
Expand All @@ -42,14 +42,9 @@ RUN bundle install && \
# Copy application code
COPY . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile



# Precompile bootsnap code and assets for production
RUN bundle exec bootsnap precompile app/ lib/ && \
SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile

# Final stage for app image
FROM base
Expand All @@ -67,6 +62,9 @@ USER 1000:1000
# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Add health check to verify the application is responding
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 CMD curl -f http://localhost:80/health || exit 1

# Start server via Thruster by default, this can be overwritten at runtime
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
5 changes: 4 additions & 1 deletion bin/docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ if [[ -z ${LD_PRELOAD+x} ]]; then
fi

# If running the rails server then create or migrate existing database
if [[ ${@: -2:1} == "./bin/rails" ]] && [[ ${@: -1:1} == "server" ]]; then
penultimate_arg="${*: -2:1}"
last_arg="${*: -1:1}"

if [[ ${penultimate_arg} == "./bin/rails" ]] && [[ ${last_arg} == "server" ]]; then
./bin/rails db:prepare
fi

Expand Down

0 comments on commit 1dfac82

Please sign in to comment.