Dockerfile 3.27 KB
Newer Older
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
1
2
3
4
# To use this Dockerfile:
# Create an empty directory and cd inside it.
# Get the source code from dt_ctrl in a subdirectry, e.g. through git:
# ```
5
# git clone https://gitlab.camras.nl/dijkema/dt_ctrl
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
6
7
# ```
# Create the docker file with `docker build --tag consoledemo .`
8
9
10
# This Dockerfile is hardcoded to run the websockets server at
# port 8000.
# Start the docker container with
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
11
12
# docker run -it -p 8081:80 -p 8000:8000 -p 11031:11031 -p 11030:11030 -p 11040:11040 -p 11041:11041 -p 11042:11042 -p 11011:11011 consoledemo
# Then visit the consoledemo from the host machine at http://localhost:8081 (NOT at port 8000, which will show a non-working HTML page)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
13
14
15
16
17
18
FROM ubuntu:16.04

RUN apt-get -y update
RUN apt-get -y install vim autoconf make gcc libtool-bin libglib2.0-dev libbison-dev flex git cmake build-essential libssl-dev screen telnet libmagic-dev wget

RUN cd /root && git clone git://git.code.sf.net/p/libnova/libnova libnova-libnova
19
RUN cd /root/libnova-libnova && git checkout 655bcd1 && libtoolize && autoreconf -i && ./configure && make install
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
20
21

RUN cd /root && git clone https://github.com/warmcat/libwebsockets.git
22
RUN cd /root/libwebsockets && git checkout v2.4.2 && mkdir build && cd build && cmake .. && make && make install
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
23

24
RUN cd /root && git clone https://gitlab.camras.nl/dijkema/dt_ctrl
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
25
26
27
28
29
30
31
32
33

RUN cd /root/dt_ctrl && autoconf && ./configure --with-libwebsockets=/usr/local && make
RUN cd /root/dt_ctrl && make console/console/console_httpd
RUN mkdir -p /var/log/dt/traces

RUN ldconfig

RUN chmod a+rwx /root
RUN mkdir -p /var/www/
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
34
RUN mkdir -p /var/www/console/htdocs/tle && cd /var/www/console/htdocs/tle && wget "http://celestrak.com/NORAD/elements/amateur.txt" -v -O amateur.txt && wget "http://celestrak.com/NORAD/elements/tle-new.txt" -v -O tle-new.txt && wget "http://celestrak.com/NORAD/elements/gps-ops.txt" -v -O gps-ops.txt && cd -
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
35

Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
36
RUN apt-get update && apt-get -y install apache2 net-tools
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

RUN mkdir -p /var/www/console/ && cp -r /root/dt_ctrl/console/htdocs /var/www/console && cp -r /root/dt_ctrl/console/js /var/www/console

# Configure apache to serve the console htdocs
RUN echo '\
<VirtualHost *:80>\n\
\tServerAdmin webmaster@localhost\n\
\tDocumentRoot /var/www/console/htdocs\n\
\t<Directory "/var/www/console/htdocs">\n\
\t\tOrder allow,deny\n\
\t\tAllow from all\n\
\t\tAllowOverride None\n\
\t\tAddHandler cgi-script .cgi\n\
\t\tOptions +ExecCGI -MultiViews +SymLinksIfOwnerMatch\n\
\t</Directory>\n\
\n\
ErrorLog ${APACHE_LOG_DIR}/error.log\n\
CustomLog ${APACHE_LOG_DIR}/access.log combined\n\
</VirtualHost>\n\
' > /etc/apache2/sites-enabled/000-default.conf

# Configure ports for the console and controller
RUN mkdir /etc/dt && echo '\
[console]\n\
host=localhost\n\
\n\
[controller]\n\
host=localhost\n\
\n\
[htdocs]\n\
path=/var/www/console/htdocs\n\
port=8000\n\
' > /etc/dt/dt_host.ini

# Patch the console software to point the websockets port
RUN sed -i -e 's/window.location.host/window.location.hostname+":8000"/' /var/www/console/htdocs/index.html && \
    sed -i -e 's/window.location.host/window.location.hostname+":8000"/' /var/www/console/htdocs/mech.html

CMD screen -d -m /root/dt_ctrl/controller/dt_ctrl /root/dt_ctrl/controller/dt_ctrl.ctrl && screen -d -m bash -c 'cd /root/dt_ctrl/console/console && ./start_console.sh' && /bin/bash -c 'service apache2 start' && bash
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
76
77

EXPOSE 80