This repository was archived by the owner on Jan 30, 2018. It is now read-only.
forked from meedan/check-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.production
More file actions
executable file
·94 lines (77 loc) · 2.45 KB
/
Copy pathDockerfile.production
File metadata and controls
executable file
·94 lines (77 loc) · 2.45 KB
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
91
92
93
94
# check-api
FROM meedan/ruby
MAINTAINER sysops@meedan.com
ENV DEPLOYUSER=checkdeploy \
DEPLOYDIR=/app \
RAILS_ENV=production \
GITREPO=git@github.com:meedan/check-api.git \
PRODUCT=check \
APP=check-api \
TERM=xterm \
MIN_INSTANCES=4 \
MAX_POOL_SIZE=12
# MIN_INSTANCES and MAX_POOL_SIZE control the pool size of passenger
#
# DEPENDENCIES
#
# nodejs7 repo
RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
# chrome repo
RUN curl -sL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
# install stuff needed to take screenshots
RUN npm install chrome-remote-interface minimist
RUN apt-get update && apt-get install -y --no-install-recommends \
imagemagick \
nodejs \
google-chrome-stable
#
# SYSTEM CONFIG
#
# nginx for check-api
COPY production/config/nginx/app.conf /etc/nginx/sites-available/${APP}
COPY production/config/nginx/test_404.conf /etc/nginx/sites-available/test_404.conf
RUN sed -i "s/ddDEPLOYUSERdd/${DEPLOYUSER}/g" /etc/nginx/sites-available/${APP} \
&& ln -s /etc/nginx/sites-available/${APP} /etc/nginx/sites-enabled/${APP} \
&& rm /etc/nginx/sites-enabled/default
#
# USER CONFIG
#
RUN useradd ${DEPLOYUSER} -s /bin/bash -m
#
# code deployment
#
RUN mkdir -p ${DEPLOYDIR}/latest \
&& chown -R ${DEPLOYUSER}:www-data ${DEPLOYDIR} \
&& chmod -R 775 ${DEPLOYDIR} \
&& chmod g+s ${DEPLOYDIR}/latest
WORKDIR ${DEPLOYDIR}
# install the gems
COPY ./Gemfile ./latest/Gemfile
COPY ./Gemfile.lock ./latest/Gemfile.lock
USER ${DEPLOYUSER}
RUN echo "gem: --no-rdoc --no-ri" > ~/.gemrc \
&& cd ./latest \
&& bundle install --jobs 20 --retry 5 --deployment --without test development
USER root
# deployment scripts
COPY production/bin /opt/bin
RUN chmod 755 /opt/bin/*
# copy in the code
COPY . ./latest
RUN chown -R ${DEPLOYUSER}:www-data ${DEPLOYDIR} \
&& chmod -R 775 ${DEPLOYDIR} \
&& chmod g+s ${DEPLOYDIR}/latest
USER ${DEPLOYUSER}
# link config files
RUN /opt/bin/find_and_link_config_files.sh ${DEPLOYDIR}/latest
# link to uploads
RUN mkdir -p ${DEPLOYDIR}/shared/files/uploads \
&& ln -s ${DEPLOYDIR}/shared/files/uploads ${DEPLOYDIR}/latest/public/uploads
RUN mv ./latest ./${APP}-$(date -I) && ln -s ./${APP}-$(date -I) ./current
#
# RUNTIME ELEMENTS
# expose, cmd
USER root
WORKDIR ${DEPLOYDIR}/current
CMD ["/opt/bin/start.sh"]