Merge "Add OSM_SERVER and OSMUI_SQL_DATABASE_URI to Dockerfile"
[osm/devops.git] / docker / light-ui / Dockerfile
1 # Copyright 2019 ETSI
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #    http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 # implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 FROM ubuntu:16.04
17
18 RUN apt-get update && apt-get install -y npm git python-pip nginx supervisor curl software-properties-common libmysqlclient-dev mysql-client
19 RUN ln -s /usr/bin/nodejs /usr/bin/node
20 RUN echo "daemon off;" >> /etc/nginx/nginx.conf
21
22 ARG REPOSITORY_BASE=http://osm-download.etsi.org/repository/osm/debian
23 ARG RELEASE=ReleaseFOUR-daily
24 ARG REPOSITORY_KEY=OSM%20ETSI%20Release%20Key.gpg
25 ARG REPOSITORY=testing
26 ARG LWUI_VERSION
27
28 RUN curl ${REPOSITORY_BASE}/${RELEASE}/${REPOSITORY_KEY} | apt-key add -
29 RUN add-apt-repository -y "deb ${REPOSITORY_BASE}/${RELEASE} ${REPOSITORY} LW-UI" && apt-get update
30
31 RUN apt-get install -y osm-lightui${LWUI_VERSION} && \
32     rm -rf /var/lib/apt/lists/*
33
34 WORKDIR /usr/share/osm-lightui
35 RUN npm install
36 RUN mv node_modules ./static
37 RUN pip install -r requirements.txt
38 RUN pip install uwsgi
39 RUN cp /usr/share/osm-lightui/nginx-app.conf /etc/nginx/sites-available/default
40 RUN cp /usr/share/osm-lightui/supervisor-app.conf /etc/supervisor/conf.d/
41
42 # delete the copy of the database inside the container (if exists)
43 RUN rm -f db.sqlite3
44
45 ENV DJANGO_ENV=prod
46 ENV OSM_SERVER=nbi
47 # ENV OSMUI_SQL_DATABASE_URI=mysql://root:secret@mysql:3306/lwui
48 RUN python manage.py collectstatic --noinput
49 RUN chmod +x /usr/share/osm-lightui/entrypoint.sh
50
51 EXPOSE 80
52
53 HEALTHCHECK --start-period=130s --interval=10s --timeout=5s --retries=12 \
54   CMD curl --silent --fail localhost:80 || exit 1
55
56 CMD ["/usr/share/osm-lightui/entrypoint.sh"]