-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (38 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
52 lines (38 loc) · 1.27 KB
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
FROM ruby:3.1.2-alpine AS Builder
ARG RAILS_ROOT=/app
ARG BUILD_PACKAGES="build-base curl-dev git"
ARG DEV_PACKAGES="sqlite-dev yaml-dev zlib-dev nodejs yarn"
ARG RUBY_PACKAGES="tzdata"
ARG SECRET_KEY_BASE
ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle"
WORKDIR $RAILS_ROOT
# Install packages
RUN apk update \
&& apk upgrade \
&& apk add --update --no-cache $BUILD_PACKAGES $DEV_PACKAGES $RUBY_PACKAGES
COPY Gemfile* package.json yarn.lock ./
# Install rubygem
COPY Gemfile* $RAILS_ROOT/
RUN bundle config --global frozen 0 \
&& bundle install --without development:test:assets -j4 --retry 3 --path=vendor/bundle
COPY . .
RUN bin/rails assets:clobber && bundle exec rails assets:precompile
# Remove folders not needed in resulting image
RUN rm -rf node_modules tmp/cache vendor/assets spec
# Build step complete.
FROM ruby:3.1.2-alpine
ARG RAILS_ROOT=/app
ARG PACKAGES="tzdata sqlite sqlite-dev nodejs bash"
ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle"
WORKDIR $RAILS_ROOT
# install packages
RUN apk update \
&& apk upgrade \
&& apk add --update --no-cache $PACKAGES
# Add user
RUN addgroup -g 1000 -S app \
&& adduser -u 1000 -S app -G app
USER app
COPY --from=Builder --chown=app:app $RAILS_ROOT $RAILS_ROOT
EXPOSE 3000
CMD ["bin/rails", "server", "-b", "0.0.0.0"]