-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathDockerfile
More file actions
110 lines (102 loc) · 3.27 KB
/
Copy pathDockerfile
File metadata and controls
110 lines (102 loc) · 3.27 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Basic Python image
FROM python:3.13-slim-trixie AS python
ENV \
PYTHONPATH=/opt
RUN \
set -x \
&& apt-get update\
&& apt-get dist-upgrade -y\
&& apt-get clean\
&& apt-get install -y --no-install-recommends \
bzip2 \
curl \
ca-certificates \
libjemalloc2 \
libpq-dev \
iproute2 \
&& (curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/usr/local/bin sh)
# Build web
FROM node:24-trixie-slim AS build-ui
COPY . /opt/noc
WORKDIR /opt/noc
RUN\
set -x\
&& apt-get update\
&& apt-get install -y --no-install-recommends \
bzip2 \
curl \
ca-certificates \
&& ./scripts/build/build-ui
# Base layer containing system packages and requirements
FROM python AS code
ENV\
DJANGO_SETTINGS_MODULE=noc.settings \
NOC_THREAD_STACK_SIZE=524288 \
NOC_PYTHON_INTERPRETER=/usr/local/bin/python3 \
NOC_LISTEN="auto:1200" \
PROJ_DIR=/usr
COPY . /opt/noc/
COPY --from=build-ui /opt/noc/ui/dist/ /www/
WORKDIR /opt/noc/
RUN \
set -x \
&& uv pip install --system -e .[bh,activator,classifier,cache-redis,node,login-ldap,login-pam,login-radius,prod-tools,testing,ping] \
&& (curl -L https://raw.githubusercontent.com/static-web-server/static-web-server/refs/tags/v2.40.1/scripts/installer.sh | sed 's/sudo //g' | sh) \
&& find /opt/noc/ -type f -name "*.py" -print0 | xargs -0 python3 -m py_compile \
&& uv cache clean \
&& rm -rf /var/lib/apt/lists/* /tmp/*.whl\
&& useradd -d /opt/noc -M -r -u 1200 -U noc -s /bin/sh \
&& chown noc /opt/noc
# https://code.getnoc.com/noc/noc/-/issues/1480
#HEALTHCHECK --interval=10s --timeout=1s \
# CMD curl -f http://0.0.0.0:1200/health/ || exit 1
#
# Developer's container
#
FROM code AS dev
ENV\
PATH=$PATH:/opt/node_modules/.bin
RUN \
apt-get update\
&& apt-get install -y --no-install-recommends \
snmp \
vim \
git \
&& uv pip install --system -e .[dev,docs,lint,test]\
&& uv cache clean \
&& (curl -fsSL https://deb.nodesource.com/setup_24.x | bash -)\
&& apt-get install -y --no-install-recommends nodejs \
&& (cd ui/ && npm install) \
&& mv ui/node_modules /opt\
&& rm -rf /var/lib/apt/lists/*
FROM python AS devcontainer
ENV\
DJANGO_SETTINGS_MODULE=noc.settings \
NOC_THREAD_STACK_SIZE=524288 \
NOC_PYTHON_INTERPRETER=/usr/local/bin/python3 \
NOC_LISTEN="auto:1200" \
PROJ_DIR=/usr\
NODE_OPTIONS=--max-old-space-size=8192\
PATH=$PATH:/workspaces/node_modules/.bin
COPY . /workspaces/noc/
WORKDIR /workspaces/noc/
RUN \
set -x \
&& apt-get update\
&& apt-get install -y --no-install-recommends \
snmp \
git \
&& uv pip install --system -e .[bh,activator,classifier,cache-redis,dev,docs,lint,node,test,login-ldap,login-pam,login-radius,prod-tools,testing,ping] \
&& uv cache clean \
&& (curl -fsSL https://deb.nodesource.com/setup_24.x | bash -)\
&& apt-get install -y --no-install-recommends nodejs \
&& (cd ui/ && npm install) \
&& mv ui/node_modules /workspaces\
&& rm -rf /var/lib/apt/lists/* /tmp/*.whl
#
# Self-serving static ui files
#
FROM nginx:alpine AS static
RUN apk add --no-cache curl
COPY --from=code /usr/local/lib/python3.12/site-packages/django /usr/lib/python3.1/site-packages/django
COPY --from=code /opt/noc/ui /opt/noc/ui