-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.pipenv
68 lines (51 loc) · 2.66 KB
/
Dockerfile.pipenv
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
ARG SR_LINUX_RELEASE
FROM srl/custombase:$SR_LINUX_RELEASE AS base
# Setup env
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
FROM base AS agent-deps
# Install pipenv and compilation dependencies
RUN sudo python3 -m pip install pipenv==2021.11.09
# RUN apt-get update && apt-get install -y --no-install-recommends gcc
# Install python dependencies in /opt/static-vxlan-agent/.venv
COPY Pipfile /opt/static-vxlan-agent/
# Lock file is created in a different environment, leave out for now
# COPY Pipfile.lock .
RUN cd /opt/static-vxlan-agent/ && \
sudo PIPENV_VENV_IN_PROJECT=1 /usr/local/bin/pipenv install --deploy --site-packages
# Install build tools, also python3-bcc
RUN sudo yum install -y gcc-c++ git python3-devel openssl-devel python3-bcc
# Need to upgrade pip and setuptools
RUN sudo python3 -m pip install --upgrade pip setuptools
# Build dependencies only installed locally
RUN cd /tmp && \
git clone https://github.com/jbemmel/grpc.git && \
cd grpc && \
git submodule update --init && \
sudo python3 -m pip install -r requirements.txt && \
sudo VIRTUAL_ENV=/opt/static-vxlan-agent/.venv GRPC_PYTHON_BUILD_WITH_CYTHON=1 /opt/static-vxlan-agent/.venv/bin/pip3 install .
# CC=/opt/rh/gcc-toolset-10/root/usr/bin/gcc GRPC_PYTHON_BUILD_WITH_CYTHON=1 GRPC_BUILD_WITH_BORING_SSL_ASM=False pip3 install .
# GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true
# GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS=1 to see errors
# Patch Ryu to support multiple VTEP endpoints per BGP speaker
COPY ryu_enhancements/ /opt/static-vxlan-agent/.venv/lib/python3.6/site-packages/ryu/services/protocols/bgp/
FROM base AS runtime
# Copy virtual env from agent-deps stage
# Also includes generated lock file, for versions (included in .rpm)
COPY --from=agent-deps /opt/static-vxlan-agent /opt/static-vxlan-agent
# Copy bcc files separately, Python bcc package is not enough
COPY --from=agent-deps /usr/lib/python3.6/site-packages/bcc /opt/static-vxlan-agent/.venv/lib/python3.6/site-packages/bcc
ENV PATH="/opt/static-vxlan-agent/.venv/bin:$PATH"
# Create and switch to a new user
# RUN useradd --create-home appuser
# WORKDIR /home/appuser
# USER appuser
# Install application into container
COPY src /opt
# run pylint to catch any obvious errors (includes .venv?)
RUN PYTHONPATH=/opt/static-vxlan-agent/.venv/lib/python3.6/site-packages/:$AGENT_PYTHONPATH pylint --load-plugins=pylint_protobuf -E /opt/static-vxlan-agent
# Using a build arg to set the release tag, set a default for running docker build manually
ARG SRL_EVPN_PROXY_RELEASE="[custom build]"
ENV SRL_EVPN_PROXY_RELEASE=$SRL_EVPN_PROXY_RELEASE