-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
71 lines (55 loc) · 2.06 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
FROM ruby:3.0.0-alpine AS build-env
ARG RAILS_ROOT=/station
ARG BUILD_PACKAGES="build-base curl-dev git bash"
ARG DEV_PACKAGES="postgresql-dev yaml-dev zlib-dev nodejs yarn shared-mime-info"
ARG RUBY_PACKAGES="tzdata"
ENV RAILS_ENV=production
ENV NODE_ENV=production
ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle"
WORKDIR $RAILS_ROOT
# Install build packages
RUN apk update \
&& apk upgrade \
&& apk add --update --no-cache $BUILD_PACKAGES $DEV_PACKAGES $RUBY_PACKAGES
COPY lib/nexmo_developer/Gemfile* package.json yarn.lock $RAILS_ROOT/
# Upgrade Bundler to version 2
RUN bundle config --global frozen 1 \
&& gem update --system \
&& gem install bundler
RUN bundle install --without development:test:assets -j4 --retry 3 --path=vendor/bundle \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf vendor/bundle/ruby/3.0.0/cache/*.gem \
&& find vendor/bundle/ruby/3.0.0/gems/ -name "*.c" -delete \
&& find vendor/bundle/ruby/3.0.0/gems/ -name "*.o" -delete
# Install node dependencies
RUN yarn install --frozen-lockfile
# Copy the app in to /station and compile assets
COPY lib/nexmo_developer/ $RAILS_ROOT/
RUN bundle exec rake assets:precompile
## Remove folders not needed in resulting image
RUN rm -rf node_modules tmp/cache vendor/assets spec
################ Build step done ###############
FROM ruby:3.0.0-alpine
ARG RAILS_ROOT=/station
ENV RACK_ENV production
ENV RAILS_ENV production
ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true
ENV DISABLE_SSL 1
ENV DOCS_BASE_PATH /docs
ENV OAS_PATH /docs/_open_api/api_specs/definitions
ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle"
WORKDIR $RAILS_ROOT
# Install packges needed at runtime
RUN apk update \
&& apk upgrade \
&& apk add --update --no-cache tzdata postgresql-client nodejs bash shared-mime-info
# Upgrade Bundler to version 2
RUN bundle config --global frozen 1 \
&& gem update --system \
&& gem install bundler
# Copy app with prebuilt assets
COPY --from=build-env $RAILS_ROOT $RAILS_ROOT
# Run the app
EXPOSE 3000
CMD ["./bin/rails", "server", "-b", "0.0.0.0"]