-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
60 lines (49 loc) · 1.96 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
###############################################################################
# 1st stage, get OUI.txt
###############################################################################
FROM alpine:3@sha256:8914eb54f968791faf6a8638949e480fef81e697984fba772b3976835194c6d4 AS oui
WORKDIR /tmp
RUN apk add --no-cache --update wget \
&& wget -O - -o /dev/null http://standards-oui.ieee.org/oui.txt | grep '(hex)' | sed -E 's/\s*?\(hex\)\s+/\t/' > OUIs.txt
###############################################################################
# 2nd stage, get wheel files
###############################################################################
FROM python:3.9-alpine@sha256:ea679ee27dbb8f36fbfc304be1b488b4fd7bea95dd230a47f97187c2e3fd4807 AS wheel
WORKDIR /wheels
# Install dependencies
RUN apk add --no-cache --update \
git \
mariadb-dev \
build-base \
libffi-dev
WORKDIR /wheels
# Install python requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -U pip \
&& pip wheel --no-cache-dir --wheel-dir /wheels -r requirements.txt
###############################################################################
# 3rd stage, deploy the application
###############################################################################
FROM python:3.9-alpine@sha256:ea679ee27dbb8f36fbfc304be1b488b4fd7bea95dd230a47f97187c2e3fd4807
RUN apk add --no-cache --update \
git \
mariadb-connector-c
EXPOSE 443
WORKDIR /adh6/api_server
RUN adduser -s /bin/bash uwsgi -h /home/uwsgi -D
COPY --from=wheel /wheels /wheels
RUN chown uwsgi:uwsgi -R /wheels
RUN pip install --no-cache-dir -U pip \
&& pip install -r /wheels/requirements.txt \
-f /wheels
USER root
RUN rm -rf /wheels
USER uwsgi
COPY --from=oui /tmp/OUIs.txt .
# Build all MIBs required by pysnmp
COPY mibs.zip .
RUN mibdump.py --mib-borrower="" --mib-source=mibs.zip CISCO-VLAN-MEMBERSHIP-MIB IF-MIB CISCO-MAC-AUTH-BYPASS-MIB IEEE8021-PAE-MIB
# Copy source files
COPY . .
# Launch the app
CMD ["uwsgi", "--ini", "uwsgi.ini"]