-
Notifications
You must be signed in to change notification settings - Fork 101
/
Dockerfile
67 lines (56 loc) · 1.61 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
FROM ruby:3.3.0-alpine3.18
# for postgres: postgresql-dev
RUN apk add --no-cache \
sqlite-dev \
tzdata \
yarn
WORKDIR /app
ARG RACK_ENV=production
ENV RACK_ENV=$RACK_ENV
ADD Gemfile* /app/
RUN set -x \
&& apk add --no-cache --virtual .build-deps \
build-base \
libxml2-dev \
libxslt-dev \
git \
&& gem install bundler \
&& bundle config set --local without 'development:test' \
&& bundle install --jobs 20 -j"$(nproc)" --retry 3 \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf \
/usr/local/bundle/cache/*.gem \
/usr/local/bundle/gems/**/*.c \
/usr/local/bundle/gems/**/*.o \
&& apk del .build-deps
COPY package.json yarn.lock /app/
RUN set -x \
&& yarn install \
&& rm -rf /tmp/*
COPY . ./
# The command '/bin/sh -c rake assets:precompile' needs the RAILS_MASTER_KEY to be set!?
# https://github.com/rails/rails/issues/32947
#
# Added xz-libs because nokogiri needs liblzma.so.5
# during rake tasks (eg. assets-precompile)
#
# Added gcompat
# https://nokogiri.org/tutorials/installing_nokogiri.html#linux-musl-error-loading-shared-library
RUN set -x \
&& apk add --no-cache xz-libs gcompat \
&& SECRET_KEY_BASE=foo bundle exec rake assets:precompile \
# Remove folders not needed in resulting image
&& rm -rf \
/tmp/* \
app/assets \
lib/assets \
node_modules \
spec \
tmp/cache \
vendor/assets
ENV RAILS_LOG_TO_STDOUT=true
ENV RAILS_SERVE_STATIC_FILES=true
ENV EXECJS_RUNTIME=Disabled
EXPOSE 3000
VOLUME /app/db/sqlite
CMD ["./start.sh"]