-
Notifications
You must be signed in to change notification settings - Fork 62
/
Dockerfile
executable file
·98 lines (88 loc) · 4.24 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
#
# Copyright (C) 2024, Broadband Forum
# Copyright (C) 2024 Vantiva
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
# file Dockerfile
#
# Used to create a docker image running OBUSPA
# Optionally may also be used to generate a build environment for building OBUSPA
# NOTE: This Dockerfile may be used standalone from the rest of the OBUSPA repository
# Basic Usage
# Create a container with latest version of OBUSPA on GitHub and all library dependencies:
# docker build --no-cache -f Dockerfile -t obuspa:latest .
#
# NOTE: The --no-cache option ensures that the container always builds
# the latest version of OBUSPA and libwebsockets
#
# Running the container with default factory reset database and arguments:
# docker run --init obuspa:latest
#
# NOTE: The --init option ensures that CTRL-C may be used to kill the container
#
# Advanced Usage
# Multi-stage build:
# 1) Build OBUSPA and all necessary library dependencies:
# docker build --no-cache -f Dockerfile -t obuspa:build-env --target build-stage .
# 2) Create a container with OBUSPA and all library dependencies
# docker build --no-cache -f Dockerfile -t obuspa:latest --target exec-stage .
#
# Running the container with factory reset file mapped into the container from
# the host, and providing the command line arguments to use when invoking OBUSPA:
# docker run --init -v [host-dir]:/usr/local/etc obuspa:latest -p -v4 -r /usr/local/etc/factory_reset.txt -f /tmp/usp.db
# where [host-dir] is a directory on the host containing the factory reset file
#
# Same as last, but additionally preserving the database between docker runs:
# docker run --init -v [host-dir]:/usr/local/etc obuspa:latest -p -v4 -r /usr/local/etc/factory_reset.txt -f /usr/local/etc/usp.db
#
# Building OBUSPA in the build environment:
# docker run --init -it obuspa:build-env
# cd /usr/local/src/obuspa
# make
#
FROM debian:stable AS build-stage
RUN apt update && apt -y install \
build-essential autoconf automake libtool pkg-config cmake git \
libssl-dev libcurl4-openssl-dev libsqlite3-dev libz-dev libmosquitto-dev
RUN mkdir -p /usr/local/src
WORKDIR /usr/local/src/
RUN git clone https://github.com/warmcat/libwebsockets.git libwebsockets
RUN cd libwebsockets && cmake . && make && make install
RUN ldconfig
RUN git clone https://github.com/BroadbandForum/obuspa.git obuspa
RUN cd obuspa && autoreconf --force --install && ./configure && make install
FROM debian:stable AS exec-stage
RUN apt update && apt -y install libssl-dev libsqlite3-dev libcurl4-openssl-dev libmosquitto-dev
WORKDIR /
COPY --from=build-stage /usr/local/lib/libwebsockets.* /usr/local/lib/
COPY --from=build-stage /usr/local/bin/obuspa /bin
COPY --from=build-stage /usr/local/src/obuspa/factory_reset_example.txt /etc
RUN ldconfig
ENTRYPOINT ["/bin/obuspa"]
CMD ["-p", "-v4", "-r", "/etc/factory_reset_example.txt", "-f", "/tmp/usp.db"]