-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
93 lines (78 loc) · 2.37 KB
/
Dockerfile
File metadata and controls
93 lines (78 loc) · 2.37 KB
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
# Compile alpr
FROM ubuntu:20.04
LABEL description="Open ALPR HTTP Wrapper"
LABEL maintainer "seanclaflin@protonmail.com"
# Workaround for devcontainer to use bash instead of sh
ENV SHELL /bin/bash
# Install prerequisites
RUN apt update \
&& apt upgrade -y \
&& DEBIAN_FRONTEND="noninteractive" \
apt install -y \
# General
git \
checkinstall \
# OpenALPR requirements
build-essential \
cmake \
libcurl3-dev \
libleptonica-dev \
liblog4cplus-dev \
libopencv-dev \
libtesseract-dev \
&& rm -rf /var/lib/apt/lists/*
# Clone the latest code from GitHub
WORKDIR /src
RUN git clone https://github.com/openalpr/openalpr.git \
&& mkdir -p openalpr/src/build
# Build & install OpenALPR
WORKDIR /src/openalpr/src/build
RUN cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc .. \
&& make \
# && make install
&& checkinstall -y --install=no --addso=yes --pakdir=/src/openalpr --pkgversion=0 --pkgname=alpr
# Build final image
FROM ubuntu:20.04
# Install prerequisites
RUN apt update \
# && apt upgrade -y \
&& DEBIAN_FRONTEND="noninteractive" \
apt install -y \
# General
lsb-release \
gnupg \
# alpr requirements
libopencv-videoio4.2 \
libopencv-video4.2 \
libopencv-highgui4.2 \
libopencv-objdetect4.2 \
libtesseract4 \
# Nodesource requirements
apt-transport-https \
wget \
&& rm -rf /var/lib/apt/lists/*
# Copy over and install alpr
COPY --from=0 /src/openalpr/alpr_0-1_amd64.deb /app/
RUN dpkg -i /app/alpr_0-1_amd64.deb
# Set up nodesource repo & install nodejs
RUN KEYRING=/usr/share/keyrings/nodesource.gpg \
&& VERSION=node_16.x \
&& DISTRO=$(lsb_release -s -c) \
&& wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee "$KEYRING" >/dev/null \
&& echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list \
&& echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list \
&& apt update \
&& apt install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Copy application files over
COPY index.js /app/
COPY config.yaml /app/
COPY package*.json /app/
COPY lib /app/lib
WORKDIR /app
RUN npm ci
# Create the application user
RUN useradd -m app
# Run as the new user
USER app
CMD ["/usr/bin/npm", "start"]