-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
61 lines (46 loc) · 1.3 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
FROM ruby:3.1-alpine AS base
ENV GROUP=edm \
USER=edm \
DIR=/project
WORKDIR $DIR
RUN apk add -U --no-cache git \
build-base \
curl \
postgresql-client \
postgresql-dev \
tzdata \
yarn && apk -U upgrade
# Ruby dependencies
COPY Gemfile Gemfile.lock $DIR/
RUN gem install bundler:"$(tail -1 < Gemfile.lock | tr -d " ")"
RUN BUNDLE_FORCE_RUBY_PLATFORM=1 BUNDLE_WITHOUT="development test beta" bundle install --jobs "$(getconf _NPROCESSORS_ONLN)" --retry 3
# JS dependencies using yarn
COPY yarn.lock $DIR/
RUN yarn install --check-files
COPY . $DIR/
RUN RAILS_ENV=production SECRET_KEY_BASE=1 bundle exec rails --trace assets:precompile assets:clean
FROM ruby:3.1-alpine
ENV GROUP=edm \
USER=edm \
DIR=/project
RUN mkdir -p "$DIR" && \
addgroup -S "$GROUP" && \
adduser -S -s /sbin/nologin -G "$GROUP" "$USER" && \
chown "$USER":"$GROUP" "$DIR"
RUN apk add -U --no-cache \
postgresql-libs \
libxml2 \
libxslt \
xz-libs \
gcompat \
tzdata \
nodejs \
curl \
&& apk -U upgrade
USER $USER
COPY --from=base --chown=$USER:$GROUP /usr/local/bundle /usr/local/bundle
COPY --from=base --chown=$USER:$GROUP $DIR/ $DIR/
WORKDIR $DIR
# Include instructions to start the Rails server...
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]