-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
82 lines (58 loc) · 1.85 KB
/
Dockerfile
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
### === base === ###
FROM ruby:3.3.6-alpine AS base
RUN apk add --no-cache --update postgresql-dev tzdata nodejs npm git
RUN gem install bundler
WORKDIR /rails
ENV BUNDLE_PATH="/usr/local/bundle"
RUN adduser -D rails && \
chown -R rails:rails /rails /usr/local/bundle
### === development === ###
FROM base AS development
RUN apk add --update build-base \
linux-headers \
gcompat \
git \
yarn \
less \
curl \
gnupg \
openssh-client \
musl musl-utils musl-locales
USER rails:rails
RUN gem install standardrb ruby-lsp debug
### === test === ###
FROM development AS test
COPY --chown=rails:rails Gemfile Gemfile.lock ./
RUN bundle install && \
bundle exec bootsnap precompile --gemfile
COPY --chown=rails:rails package.json yarn.lock ./
RUN yarn install
COPY --chown=rails:rails . .
RUN bundle exec bootsnap precompile app/ lib/
### === build === ###
FROM base AS build
RUN apk add --update build-base yarn
USER rails:rails
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_WITHOUT="development" \
NODE_ENV="production"
COPY --chown=rails:rails Gemfile Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile
COPY --chown=rails:rails package.json yarn.lock ./
RUN yarn install
COPY --chown=rails:rails . .
RUN bundle exec bootsnap precompile app/ lib/ && \
bin/vite build
### === production === ###
FROM base AS production
EXPOSE 3000
CMD ["bin/rails", "s", "-b", "0.0.0.0"]
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_WITHOUT="development"
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails
USER rails:rails