-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
63 lines (48 loc) · 1.82 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
FROM ruby:3.2.2-alpine3.18 AS builder
WORKDIR /app
# install packages
ARG BUILD_PACKAGES="build-base curl-dev git"
ARG DEV_PACKAGES="yaml-dev zlib-dev libxml2-dev libxslt-dev nodejs yarn"
ARG RUBY_PACKAGES="tzdata shared-mime-info"
RUN apk add --no-cache $BUILD_PACKAGES $DEV_PACKAGES $RUBY_PACKAGES
# install rubygem
COPY Gemfile Gemfile.lock ./
COPY vendor/cache ./vendor/cache
COPY node_modules ./node_modules
COPY public/assets ./public/assets
RUN gem install bundler -v $(tail -n1 Gemfile.lock) \
&& bundler config without 'development:test' \
&& bundle config frozen 1 \
&& bundle install --path=vendor/cache --jobs=4 --retry=3 \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf $GEM_HOME/cache/*.gem \
&& find $GEM_HOME/gems/ -name "*.c" -delete \
&& find $GEM_HOME/gems/ -name "*.o" -delete
COPY package.json yarn.lock ./
RUN yarn install --production
COPY . .
# compile the assets
ARG RAILS_ENV="production"
ENV RAILS_ENV=$RAILS_ENV
RUN bin/rails assets:precompile
RUN rm -rf tmp/cache vendor/assets spec node_modules
############### Build step done ###############
FROM ruby:3.2.2-alpine3.18
WORKDIR /app
# install packages
ARG PACKAGES="build-base tzdata libxslt libxml2-dev libxslt-dev nodejs"
RUN apk add --no-cache $PACKAGES
# This is needed for the pipeline build (it breaks without the freedesktop package).
# There is no newer version of buster, so we will keep using this version for now
COPY --from=ruby:3.0.0-buster /usr/share/mime/packages/freedesktop.org.xml /usr/share/mime/packages/
# get the application code
COPY --from=builder $GEM_HOME $GEM_HOME
COPY --from=builder /app /app
# Change TimeZone
ARG TIMEZONE="Pacific/Auckland"
ENV TIMEZONE=$TIMEZONE
ENV TZ=$TIMEZONE
ARG RAILS_ENV="production"
ENV RAILS_ENV=$RAILS_ENV
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]