-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
69 lines (53 loc) · 1.87 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
FROM ruby:2.5-alpine
RUN mkdir -p /opt/trainers-hub
WORKDIR /opt/trainers-hub
ARG BUILD_ENV=production
RUN if [ "$BUILD_ENV" = "development" ]; then \
adduser -Du 1000 -h /opt/trainers-hub www-data; \
else \
adduser -DS -h /opt/trainers-hub www-data; \
fi
ENV BUNDLER_VERSION="2.0.1"
RUN echo "@edge http://nl.alpinelinux.org/alpine/edge/main" >>/etc/apk/repositories \
&& echo "@edgecommunity http://nl.alpinelinux.org/alpine/edge/community" >>/etc/apk/repositories \
&& apk upgrade --update-cache \
&& apk add \
build-base \
postgresql-dev \
postgresql-client \
graphicsmagick \
ghostscript \
nodejs \
yarn \
zip \
# Use Bundler 2.
&& gem install bundler -v "$BUNDLER_VERSION" --force \
# Set up crontab.
&& echo "*/15 * * * * su -s/bin/sh www-data -c \
'cd /opt/trainers-hub && bundle exec rake blog:update' >>/proc/1/fd/1 2>&1" >>/etc/crontabs/root \
&& echo "*/15 * * * * root su -s/bin/sh www-data -c \
'cd /opt/trainers-hub && bundle exec rake glossary:update' >>/proc/1/fd/1 2>&1" >>/etc/crontab
ENV CHROME_BIN=/usr/bin/chromium-browser
ENV CHROME_PATH=/usr/lib/chromium/
COPY Gemfile* ./
COPY ./vendor/active_material ./vendor/active_material
RUN bundle install
COPY package.json ./
COPY yarn.lock ./
RUN yarn install
COPY . .
RUN cp ./app/assets/fonts/* /usr/share/fonts
RUN if [ "$BUILD_ENV" = "production" ]; \
then bundle exec rake assets:precompile \
RAILS_ENV=production \
SECRET_KEY_BASE=noop \
DATABASE_URL=postgres://noop; fi
RUN mkdir -p /var/www /opt/trainers-hub/files \
&& chown -R www-data /opt/trainers-hub/public \
/opt/trainers-hub/files \
/opt/trainers-hub/tmp \
/var/www \
/usr/local/bundle
USER www-data
CMD ["rails", "s", "-b", "0.0.0.0"]
ENTRYPOINT ["/opt/trainers-hub/entrypoint.sh"]