-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
58 lines (40 loc) · 1.56 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
FROM ruby:3.2.2-alpine3.18 AS builder
ARG BUILD_PACKAGES="build-base curl-dev git"
ARG DEV_PACKAGES="yaml-dev zlib-dev libxml2-dev libxslt-dev"
ARG RUBY_PACKAGES="tzdata shared-mime-info"
WORKDIR /app
# install packages
RUN apk add --no-cache $BUILD_PACKAGES $DEV_PACKAGES $RUBY_PACKAGES
COPY Gemfile Gemfile.lock ./
COPY vendor/cache ./vendor/cache
# install rubygem
RUN gem install bundler -v $(tail -n1 Gemfile.lock) \
&& bundle config --global frozen 1 \
&& bundle install --path=vendor/cache --without development:test:assets -j4 --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
# Change TimeZone
ENV TZ=Pacific/Auckland
COPY . .
ARG RAILS_ENV="production"
ARG SECRET_KEY_BASE
ENV RAILS_ENV=$RAILS_ENV
############### Build step done ###############
FROM ruby:3.2.2-alpine3.18
ARG PACKAGES="build-base tzdata bash libxslt libxml2-dev libxslt-dev"
# Change TimeZone
ENV TZ=Pacific/Auckland
WORKDIR /app
# install packages
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/
COPY --from=builder $GEM_HOME $GEM_HOME
COPY --from=builder /app /app
ARG RAILS_ENV="production"
ENV RAILS_ENV=$RAILS_ENV
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]