forked from evans22j/Budget-App
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.multistaging
67 lines (50 loc) · 1.87 KB
/
Dockerfile.multistaging
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Build stage
FROM ruby:3.1.4 AS build
WORKDIR /app
# Install system dependencies and cleanup
RUN apt-get update -qq && \
apt-get install -y build-essential libvips bash bash-completion libffi-dev tzdata postgresql nodejs npm yarn && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man
# Copy Gemfile and Gemfile.lock to the build stage
COPY Gemfile Gemfile.lock ./
# Install gems (dependencies) for the application
RUN bundle install
# Copy the rest of the application source code
COPY . .
# Set production environment variables
ENV RAILS_LOG_TO_STDOUT="1" \
RAILS_SERVE_STATIC_FILES="true" \
RAILS_ENV="production" \
BUNDLE_WITHOUT="development"
# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile --gemfile app/ lib/
# Build the application (you may customize this step)
RUN bundle exec rake assets:precompile
# Runtime stage
FROM ruby:3.1.4-slim
WORKDIR /app
# Install the PostgreSQL Client in the Runtime Stage
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
libpq-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man
# Set production environment variables
ENV RAILS_LOG_TO_STDOUT="1" \
RAILS_SERVE_STATIC_FILES="true" \
RAILS_ENV="production" \
BUNDLE_WITHOUT="development"
# Copy installed dependiencies gem
COPY --from=build /usr/local/bundle /usr/local/bundle
# Copy all of the application's assets to the production image (assets:precompile)
COPY --from=build app/public/assets /app/public/assets
# Copy bootsnap code for faster boot times
COPY --from=build app/tmp/cache/bootsnap /lib/
COPY . .
EXPOSE 3000
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
# Start your application (adjust the command as needed)
CMD ["rails", "server", "-b", "0.0.0.0"]