-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
90 lines (76 loc) · 3.13 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
FROM ruby:2.5
# Setup build variables
ARG RAILS_ENV
ARG DERIVATIVES_PATH
ARG UPLOADS_PATH
ARG CACHE_PATH
ARG FITS_PATH
ARG FITS_VERSION
ENV APP_PRODUCTION=/data/ \
APP_WORKDIR=/data \
BUNDLER_VERSION=2.1.4
# Add backports to apt-get sources
# Install libraries, dependencies, java and fits
RUN echo 'deb http://deb.debian.org/debian buster main contrib non-free'
RUN echo 'deb-src http://deb.debian.org/debian buster main contrib non-free'
RUN apt-get update -qq && \
apt-get -y install apt-transport-https && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
apt-get update -qq && apt-get install -y --no-install-recommends \
libpq-dev \
libxml2-dev libxslt1-dev \
nodejs \
libreoffice \
libass-dev libfreetype6-dev libmp3lame-dev libopus-dev libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev \
libvpx-dev libvorbis-dev libx264-dev libx265-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev nasm pkg-config \
texinfo wget yasm zlib1g-dev fonts-ipaexfont fonts-ipafont fonts-vlgothic \
libjpeg-dev libtiff-dev libpng-dev libraw-dev libwebp-dev libjxr-dev \
libcairo2-dev libgs-dev librsvg2-dev \
libmp3lame-dev libvorbis-dev libtheora-dev libspeex-dev libx264-dev \
ghostscript ffmpeg imagemagick \
ufraw \
bzip2 unzip xz-utils \
vim \
git \
openjdk-11-jre-headless \
yarn && \
yarn config set no-progress && \
yarn config set silent
RUN mkdir -p /fits/ \
&& wget -q https://projects.iq.harvard.edu/files/fits/files/$FITS_VERSION.zip -O /fits/$FITS_VERSION.zip \
&& unzip -q /fits/$FITS_VERSION.zip -d /fits/$FITS_VERSION \
&& chmod a+x $FITS_PATH \
&& rm /fits/$FITS_VERSION.zip
# copy gemfiles to production folder
COPY Gemfile Gemfile.lock $APP_PRODUCTION
# install gems to system - use flags dependent on RAILS_ENV
RUN cd $APP_PRODUCTION && \
gem install bundler && \
bundle config build.nokogiri --use-system-libraries \
&& if [ "$RAILS_ENV" = "production" ]; then \
bundle install --without test:development; \
else \
bundle install --without production --no-deployment; \
fi \
&& mv Gemfile.lock Gemfile.lock.built_by_docker
# create a folder to store derivatives, file uploads and cache directory
RUN mkdir -p $DERIVATIVES_PATH
RUN mkdir -p $UPLOADS_PATH
RUN mkdir -p $CACHE_PATH
# copy the application
COPY . $APP_PRODUCTION
COPY docker-entrypoint.sh /bin/
# use the just built Gemfile.lock, not the one copied into the container and verify the gems are correctly installed
RUN cd $APP_PRODUCTION \
&& mv Gemfile.lock.built_by_docker Gemfile.lock \
&& bundle check
# generate production assets if production environment
RUN if [ "$RAILS_ENV" = "production" ]; then \
cd $APP_PRODUCTION \
&& yarn install \
&& SECRET_KEY_BASE_PRODUCTION=0 FLUENTD_URL=$FLUENTD_URL bundle exec rake assets:clean assets:precompile; \
fi
WORKDIR $APP_WORKDIR
RUN chmod +x /bin/docker-entrypoint.sh