-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathDockerfile
171 lines (149 loc) · 5.79 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# AUTHOR: Nicholas Long
# DESCRIPTION: OpenStudio Server Docker Container
# TO_BUILD_AND_RUN: docker-compose up
# NOTES: Currently this is one big dockerfile and non-optimal.
#may include suffix
ARG OPENSTUDIO_VERSION=3.7.0
FROM nrel/openstudio:3.7.0 as base
MAINTAINER Nicholas Long [email protected]
ENV DEBIAN_FRONTEND=noninteractive
# Install required libaries.
# realpath - needed for wait-for-it
RUN apt-get update && apt-get install -y wget gnupg \
&& wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add - \
&& echo "deb http://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | \
tee /etc/apt/sources.list.d/mongodb-org-6.0.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
autoconf \
bison \
shared-mime-info \
build-essential \
bzip2 \
ca-certificates \
curl \
default-jdk \
dos2unix \
imagemagick \
gdebi-core \
git \
libbz2-dev \
libcurl4-openssl-dev \
libdbus-glib-1-2 \
libgdbm-dev \
libglib2.0-dev \
libglu1 \
libgsl0-dev \
libncurses-dev \
libreadline-dev \
libxml2-dev \
libxslt-dev \
libffi-dev \
libssl-dev \
libyaml-dev \
libice-dev \
libsm-dev \
mongodb-database-tools \
nodejs \
procps \
python-numpy \
python3-numpy \
tar \
unzip \
wget \
zip \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# Install passenger (this also installs nginx)
ENV PASSENGER_VERSION 6.0.18
RUN gem install passenger -v $PASSENGER_VERSION
RUN passenger-install-nginx-module
# Configure the nginx server
RUN mkdir /var/log/nginx
ADD /docker/server/nginx.conf /opt/nginx/conf/nginx.conf
# Radiance env vars. RUBYLIB is set in the base openstudio container
ENV OPENSTUDIO_SERVER 'true'
ENV OS_RAYPATH /usr/local/openstudio-$OPENSTUDIO_VERSION/Radiance
ENV PERL_EXE_PATH /usr/bin
# Specify a couple arguments here, after running the majority of the installation above
ARG rails_env=docker
ARG bundle_args="--without development test"
ENV OS_BUNDLER_VERSION=2.1.4
# Set the rails env var
ENV RAILS_ENV $rails_env
# extension gem testing
#ENV FAVOR_LOCAL_GEMS 1
#### OpenStudio Server Code
# First upload the Gemfile* so that it can cache the Gems -- do this first because it is slow
ADD /bin /opt/openstudio/bin
ADD /server/Gemfile /opt/openstudio/server/Gemfile
WORKDIR /opt/openstudio/server
RUN bundle _${OS_BUNDLER_VERSION}_ install --jobs=3 --retry=3 $bundle_args
# Add the app assets and precompile assets. Do it this way so that when the app changes the assets don't
# have to be recompiled everytime
ADD /server/Rakefile /opt/openstudio/server/Rakefile
ADD /server/config/ /opt/openstudio/server/config/
ADD /server/app/assets/ /opt/openstudio/server/app/assets/
# Now call precompile
RUN mkdir /opt/openstudio/server/log
RUN bundle exec rake assets:precompile
# Bundle app source
ADD /server /opt/openstudio/server
# Add in /spec for testing
#ADD /server/spec /opt/openstudio/server/spec
ADD .rubocop.yml /opt/openstudio/.rubocop.yml
# Run bundle again, because if the user has a local Gemfile.lock it will have been overriden
RUN rm Gemfile.lock
RUN bundle install --jobs=3 --retry=3
# Add in scripts for running server. This includes the wait-for-it scripts to ensure other processes (mongo, redis) have
# started before starting the main process.
COPY /docker/server/wait-for-it.sh /usr/local/bin/wait-for-it
COPY /docker/server/start-server.sh /usr/local/bin/start-server
COPY /docker/server/rails-entrypoint.sh /usr/local/bin/rails-entrypoint
COPY /docker/server/start-web-background.sh /usr/local/bin/start-web-background
COPY /docker/server/start-workers.sh /usr/local/bin/start-workers
COPY /docker/server/requeue.rb /opt/openstudio/server/bin/requeue.rb
COPY /docker/server/aws_imdsv2.sh /opt/openstudio/server/bin/aws_imdsv2
RUN chmod 755 /usr/local/bin/wait-for-it
RUN chmod +x /usr/local/bin/start-server
RUN chmod 755 /usr/local/bin/rails-entrypoint
RUN chmod 755 /usr/local/bin/start-web-background
RUN chmod 755 /usr/local/bin/start-workers
RUN chmod 755 /opt/openstudio/server/bin/requeue.rb
RUN chmod 755 /opt/openstudio/server/bin/aws_imdsv2
# set the permissions for windows users
RUN chmod +x /opt/openstudio/server/bin/*
ENV OPENSTUDIO_EXE_PATH /usr/local/bin/openstudio
# Remove leftover install files from openstudio base container
RUN rm /OpenStudio-*.deb
RUN rm /ruby-2.7.2.tar.gz
ENTRYPOINT ["rails-entrypoint"]
CMD ["/usr/local/bin/start-server"]
# Expose ports.
EXPOSE 8080 9090
# Multistage build includes test library. To build without testing run
# docker build --target base -t some-tag .
FROM base
ENV GECKODRIVER_VERSION v0.21.0
# Install vfb and firefox requirement if docker-test env
RUN echo "Running in testing environment - Installing Firefox and Gecko Driver" && \
apt-get update && \
apt-get install -y xvfb \
x11-xkb-utils \
xfonts-100dpi \
xfonts-75dpi \
xfonts-scalable \
xfonts-cyrillic \
firefox && \
rm -rf /var/lib/apt/lists/* && \
cd /usr/local/bin && \
wget http://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \
tar -xvzf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \
rm geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \
chmod +x geckodriver;
COPY /docker/server/run-server-tests.sh /usr/local/bin/run-server-tests
RUN chmod +x /usr/local/bin/run-server-tests
# Test adding the git repo to the container for coveralls
# The #TEST# will be removed in the test script to be run in the test container
#TEST#COPY .git /opt/openstudio/.git