From 956377031d1a6ba80565af7a430834e51a40eb7a Mon Sep 17 00:00:00 2001 From: Dwarakanath Yadavalli Date: Sat, 10 Aug 2024 12:04:44 +0530 Subject: [PATCH 1/2] Update Docker file to use the latest Alpine --- Dockerfile | 26 ++++++++++++++++---------- README.md | 20 ++++++++++++++------ 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index e5a3afdfa..bb765eb62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.12 +FROM alpine:3.20.2 LABEL net.juniper.description="Junos PyEZ library for Python in a lightweight container." \ - net.juniper.maintainer="Stephen Steiner " + net.juniper.maintainer="jnpr-community-netdev@juniper.net" WORKDIR /source @@ -12,15 +12,21 @@ ADD requirements.txt . ADD lib lib ADD entrypoint.sh /usr/local/bin/. -## Install dependancies and PyEZ -RUN apk add --no-cache build-base python3-dev py-lxml \ +## Install dependencies +RUN apk add --no-cache build-base python3-dev \ libxslt-dev libxml2-dev libffi-dev openssl-dev curl \ - ca-certificates py3-pip bash \ - && pip install -U pip \ - && pip install -r requirements.txt \ - && apk del -r --purge gcc make g++ \ - && ln -s /usr/bin/python3 /usr/bin/python \ - && pip install . \ + ca-certificates py3-pip bash + +## Update as per PEP 668. Use Virtual Env +RUN python3 -m venv /scripts/.venv \ + && source /scripts/.venv/bin/activate \ + && pip install --upgrade pip \ + && pip install pipdeptree \ + && python3 -m pip install -r requirements.txt \ + && pip install . + +## Clean up and start init +RUN apk del -r --purge gcc make g++ \ && rm -rf /source/* \ && chmod +x /usr/local/bin/entrypoint.sh diff --git a/README.md b/README.md index bc1f48c9e..17bf7d327 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This means that "non-programmers", for example the _Network Engineer_, can use t ## For "Programmers" - Open and Extensible -There is a growing interest and need to automate the network infrastructure into larger IT systems. To do so, traditional software programmers, DevOps, "hackers", etc. need an abstraction library of code to further those activities. _Junos PyEZ_ is designed for extensibility so that the programmer can quickly and easily add new widgets to the library in support of their specific project requirements. There is no need to "wait on the vendor" to provide new functionality. _Junos PyEZ_ is not specifically tied to any version of Junos or any Junos product family. +There is a growing interest and need to automate the network infrastructure into larger IT systems. To do so, traditional software programmers, DevOps, "hackers", etc. need an abstraction library of code to further those activities. _Junos PyEZ_ is designed for extensibility so that the programmer can quickly and easily add new widgets to the library in support of their specific project requirements. There is no need to "wait on the vendor" to provide new functionality. _Junos PyEZ_ is not specifically tied to any version of Junos (or Junos Evolved) or any Junos (or Junos Evolved) product family. # SUPPORT @@ -37,7 +37,7 @@ For questions and general support, please visit our [Google Group](https://group You can also post your query on stackoverflow with __pyez__ [tag](http://stackoverflow.com/questions/tagged/pyez) -For documentation and more usage examples, please visit the _Junos PyEZ_ project page, [here](http://forums.juniper.net/t5/Automation/Where-can-I-learn-more-about-Junos-PyEZ/ta-p/280496). +For documentation and more usage examples, please visit the _Junos PyEZ_ project page, [here](http://www.juniper.net/techpubs/en_US/release-independent/junos-pyez/information-products/pathway-pages/index.html). Issues and bugs can be opened in the repository. @@ -54,7 +54,7 @@ _Junos PyEZ_ is designed to provide the same capabilities as a user would have o # NOTICES -- As of release 2.0.0, _Junos PyEZ_ requires [ncclient](https://pypi.python.org/pypi/ncclient) version 0.5.2 or later. +- As of release 2.7.1, _Junos PyEZ_ requires [ncclient](https://pypi.python.org/pypi/ncclient) version 0.6.15 or later. - When using the `ssh_private_key_file` argument of the Device constructor on MacOS Mojave and higher, ensure that the SSH keys are in the RSA format, and not the newer OPENSSH format. - New key: `ssh-keygen -p -m PEM -f ~/.ssh/id_rsa` - Convert an existing OPENSSH key: ``ssh-keygen -p -m PEM -f ~/.ssh/private_key` @@ -88,11 +88,16 @@ Move to the local directory which contains your script(s) and run the container. Your local scripts will be mounted to /scripts in the container. +As per PEP 668, use Virtual Env in the container (after you enter the container). The docker container has virtual environment installed in the /scripts folder. + +Use `source .venv/bin/activate` to activate the virtual environment. + + ### Microservice Usage This image can also be used as a Python "executable" with the required Python PyEZ libraries pre-installed. To use the image in this way, mount the volume which contains the Python script and pass the script name as an argument to `docker run`. Optionally, you may also pass in a `requirements.txt` file to install additional python packages via `pip`. To add OS packages (Alpine Linux), provide a file with a list of packages --one per line-- and either reference it as an env var (`$APK`) or mount it to the container `/extras/apk.txt`. To add additional Python packages (via pip), provide a `requirements.txt` file and pass it in as an env var (`$REQ`) or mount it to the container at `/extras/requirements.txt`. -`Usage: `docker run -it [ --rm ] -v some/dir:/scripts juniper/pyez [ myscript.py ]` +Usage: `docker run -it [ --rm ] -v some/dir:/scripts juniper/pyez [ myscript.py ]` Example: @@ -153,8 +158,11 @@ Juniper Networks is actively contributing to and maintaining this repo. Please c *Contributors:* -[Nitin Kumar](https://github.com/vnitinv), [Stacy Smith](https://github.com/stacywsmith), [Stephen Steiner](https://github.com/ntwrkguru) +* v2.7.1: [Dinesh Babu](https://github.com/dineshbaburam91) +* v2.6.4: [Chidanand Pujar](https://github.com/chidanandpujar) +* v2.6.3: [Rahul Kumar](https://github.com/rahkumar651991) +* v2.5.0: [Rahul Kumar](https://github.com/rahkumar651991) * v2.4.1: [Nitin Kumar](https://github.com/vnitinv) * v2.4.0: [Nitin Kumar](https://github.com/vnitinv) * v2.3.0: [Nitin Kumar](https://github.com/vnitinv), [Raja Shekar Mekala](https://github.com/rsmekala), [Dinesh Babu](https://github.com/dineshbaburam91), [Chris Jenn](https://github.com/ipmonk), [Shigechika](https://github.com/shigechika) @@ -167,4 +175,4 @@ Juniper Networks is actively contributing to and maintaining this repo. Please c *Former Contributors:* -[Jeremy Schulman](https://github.com/jeremyschulman), [Rick Sherman](https://github.com/shermdog), [Edward Arcuri](https://github.com/sdndude) +[Jeremy Schulman](https://github.com/jeremyschulman), [Rick Sherman](https://github.com/shermdog), [Edward Arcuri](https://github.com/sdndude), [Nitin Kumar](https://github.com/vnitinv), [Stacy Smith](https://github.com/stacywsmith), [Stephen Steiner](https://github.com/ntwrkguru) From 027cbb19ba3452de8ef808cdc721e9cdbae7d8df Mon Sep 17 00:00:00 2001 From: Dinesh babu Date: Mon, 7 Oct 2024 15:29:57 +0530 Subject: [PATCH 2/2] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bb765eb62..9b9c6a4c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ LABEL net.juniper.description="Junos PyEZ library for Python in a lightweight co WORKDIR /source -## Copy project inside the container +## Copy project inside the containers ADD setup.* ./ ADD versioneer.py . ADD requirements.txt .