-
Notifications
You must be signed in to change notification settings - Fork 44
/
Dockerfile
67 lines (52 loc) · 2.12 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
ARG NAUTOBOT_VERSION
ARG PYTHON_VER
FROM ghcr.io/nautobot/nautobot:${NAUTOBOT_VERSION}-py${PYTHON_VER} as nautobot-base
USER 0
RUN apt-get update && \
apt-get upgrade -y && \
apt-get autoremove -y && \
apt-get clean all && \
rm -rf /var/lib/apt/lists/* && \
pip --no-cache-dir install --upgrade pip wheel
FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VERSION}-py${PYTHON_VER} as builder
CMD ["nautobot-server", "runserver", "0.0.0.0:8080", "--insecure"]
RUN apt-get update && \
apt-get upgrade -y && \
apt-get autoremove -y && \
apt-get clean all && \
rm -rf /var/lib/apt/lists/*
COPY ../pyproject.toml ../poetry.lock /source/
COPY ../plugins /source/plugins
# COPY ../packages /source/packages
# Install the nautobot project to include Nautobot
RUN cd /source && \
poetry install --no-interaction --no-ansi && \
mkdir /tmp/dist && \
poetry export --without-hashes -o /tmp/dist/requirements.txt
# -------------------------------------------------------------------------------------
# Build Apps in plugins folder
# -------------------------------------------------------------------------------------
RUN for plugin in /source/plugins/*; do \
cd $plugin && \
poetry build && \
cp dist/*.whl /tmp/dist; \
done
COPY ../jobs /opt/nautobot/jobs
# COPY ../metrics /opt/nautobot/metrics
COPY ../config/nautobot_config.py /opt/nautobot/nautobot_config.py
WORKDIR /source
###################################
# -------------------------------------------------------------------------------------
# Final Image
# -------------------------------------------------------------------------------------
FROM nautobot-base as nautobot
# Copy from base the required python libraries and binaries
COPY --from=builder /tmp/dist /tmp/dist
COPY --from=builder /opt/nautobot /opt/nautobot
# COPY ../packages /source/packages
RUN grep -v /source/plugins /tmp/dist/requirements.txt > /tmp/dist/new_requirements.txt && \
pip install -r /tmp/dist/new_requirements.txt && \
pip install /tmp/dist/*.whl && \
rm -rf /source /tmp/dist && \
chown -R nautobot:nautobot /opt/nautobot
USER nautobot