-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
135 lines (113 loc) · 5.11 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
#STEP 1 of multistage build ---Compile opc ua library ---
#use armv7hf compatible base image
FROM balenalib/armv7hf-debian:stretch-20191223 as builder
#install tools for building the open64541 library
RUN apt-get update \
&& apt-get install git build-essential gcc pkg-config cmake python wget \
&& apt-get install cmake-curses-gui \
&& apt-get install libmbedtls-dev \
&& apt-get install check \
&& apt-get install python-sphinx graphviz \
&& apt-get install python-sphinx-rtd-theme
#compile the SSL library
RUN git clone https://github.com/ARMmbed/mbedtls --branch mbedtls-2.16.1 \
&& cd mbedtls \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make
#install open62541 stack
RUN wget https://github.com/open62541/open62541/archive/v1.1-rc1.tar.gz \
&& tar -xvf v1.1-rc1.tar.gz \
&& mkdir ./open62541-1.1-rc1/deps/ua-nodeset/Schema/ \
&& wget https://github.com/OPCFoundation/UA-Nodeset/archive/UA-1.04.6-2020-04-14.tar.gz \
&& tar -xvf UA-1.04.6-2020-04-14.tar.gz \
&& cp UA-Nodeset-UA-1.04.6-2020-04-14/Schema/* ./open62541-1.1-rc1/deps/ua-nodeset/Schema/ \
&& cd open62541-1.1-rc1 \
&& mkdir build \
&& mkdir build_encr \
&& cd build_encr \
&& cmake .. -DUA_NAMESPACE_ZERO=FULL -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_ENCRYPTION=ON -DMBEDTLS_INCLUDE_DIRS=/mbedtls/build/include \
-DMBEDTLS_LIBRARY=/mbedtls/build/library -DMBEDX509_LIBRARY=/mbedtls/build/library -DMBEDCRYPTO_LIBRARY=/mbedtls/build/library \
&& make \
&& cd ../build \
&& cmake .. -DUA_NAMESPACE_ZERO=FULL -DCMAKE_BUILD_TYPE=Release \
&& make
#STEP 2 of multistage build ----Create the final image-----
#use armv7hf compatible base image
FROM balenalib/armv7hf-debian:stretch-20191223
#dynamic build arguments coming from the /hook/build file
ARG BUILD_DATE
ARG VCS_REF
#metadata labels
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/HilscherAutomation/netPI-opcua-server" \
org.label-schema.vcs-ref=$VCS_REF
#version
ENV HILSCHERNETPI_OPCUA_SERVER_VERSION 1.2.1
#labeling
LABEL maintainer="netpi@hilscher.com" \
version=$HILSCHERNETPI_OPCUA_SERVER_VERSION \
description="OPC UA Server"
RUN apt-get update \
&& apt-get install -y build-essential curl python python-pip python-dev \
&& echo 'root:root' | chpasswd
#install python tools
RUN pip install --upgrade setuptools \
&& pip install --upgrade wheel \
&& pip install --upgrade netifaces
# create all necessary folders
RUN mkdir -p ./open62541/html/certs_copy \
&& mkdir -p ./mbedtls/build/library \
&& mkdir -p ./mbedtls/build/include/mbedtls \
&& mkdir -p ./open62541/deps/ua-nodeset/Schema/ \
&& mkdir -p ./open62541/tools/nodeset_compiler/ \
&& mkdir -p ./open62541/tools/certs/ \
&& mkdir -p ./open62541/include/open62541/ \
&& mkdir -p ./open62541/plugins/include/ \
&& mkdir -p ./open62541/arch/ \
&& mkdir -p ./open62541/build/bin \
&& mkdir -p ./open62541/build_encr/bin \
&& mkdir -p ./open62541/build/src_generated/ \
&& mkdir -p ./open62541/build_encr/src_generated/ \
&& mkdir -p ./open62541/examples/
#install node.js and npm modules
RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - \
&& apt-get install -y nodejs \
&& cd ./open62541/html \
&& npm install formidable \
&& npm install tree-kill \
&& npm install find-process \
&& npm install url \
&& rm -rf /tmp/* \
&& rm -rf /var/lib/apt/lists/*
#copy the html application
COPY "./html/*.*" ./open62541/html/
#copy include files and library from STEP 1 build
COPY --from=builder /open62541-1.1-rc1/deps /open62541/deps/
COPY --from=builder /open62541-1.1-rc1/deps/ua-nodeset /open62541/deps/ua-nodeset/
COPY --from=builder /open62541-1.1-rc1/deps/ua-nodeset/Schema /open62541/deps/ua-nodeset/Schema/
COPY --from=builder /open62541-1.1-rc1/deps /open62541/deps/
COPY --from=builder /open62541-1.1-rc1/plugins /open62541/plugins/
COPY --from=builder /open62541-1.1-rc1/plugins/include /open62541/plugins/include/
COPY --from=builder /open62541-1.1-rc1/include/open62541 /open62541/include/open62541/
COPY --from=builder /open62541-1.1-rc1/arch /open62541/arch/
COPY --from=builder /open62541-1.1-rc1/build/bin /open62541/build/bin/
COPY --from=builder /open62541-1.1-rc1/build_encr/bin /open62541/build_encr/bin/
COPY --from=builder /open62541-1.1-rc1/build/src_generated /open62541/build/src_generated/
COPY --from=builder /open62541-1.1-rc1/build_encr/src_generated /open62541/build_encr/src_generated/
COPY --from=builder /open62541-1.1-rc1/tools/nodeset_compiler /open62541/tools/nodeset_compiler/
COPY --from=builder /open62541-1.1-rc1/tools/certs /open62541/tools/certs/
COPY --from=builder /open62541-1.1-rc1/examples/common.h /open62541/examples/common.h
COPY --from=builder /mbedtls/build/library /mbedtls/build/library/
COPY --from=builder /mbedtls/build/include/mbedtls /mbedtls/build/include/mbedtls/
#set workdir
WORKDIR /open62541/html/
#copy entrypoint file
COPY "./init.d/*" /etc/init.d/
#set the entrypoint
ENTRYPOINT ["/etc/init.d/entrypoint.sh"]
#Ports
EXPOSE 4840 8080
#set STOPSGINAL
STOPSIGNAL SIGTERM