openkbs/jdk-mvn-py3
Java 8/11 OpenJDK + Maven + Python 3+ pip + node + npm + Gradle
100K+
Please consider to donate what you can to help UNICEF, WHO, and Red Cross if you like what we provide to you for free. Thanks so much!
World Health Organization (WHO) COVID-19 Solidarity Response Fund
Help UNICEF’s COVID-19 Response
Help Red Cross
This build is based upon Ubuntu 18.04 + OpenJDK Java 11
Non-Root
implementationThis new release is designed to support the deployment for Non-Root child images implementations and deployments to platform such as OpenShift or RedHat host operating system which requiring special policy to deploy. And, for better security practice, we decided to migrate (eventaully) our Docker containers to use Non-Root implementation.
Here are some of the things you can do if your images requiring "Root" acccess - you really
want to do it:
We like to promote the use of "Non-Root" images as better Docker security practice. And, whenever possible, you also want to further confine the use of "root" privilges in your Docker implementation so that it can prevent the "rooting hacking into your Host system". To lock down your docker images and/or this base image, you will add the following line at the very end to remove sudo: (Notice that this might break some of your run-time code if you use sudo during run-time)
sudo agt-get remove -y sudo
After that, combining with other Docker security practice (see below references), you just re-build your local images and re-deploy it as non-development quality of docker container. However, there are many other practices to secure your Docker containes. See below:
Yarn has now been added since few requests for supporting Yarn. However, at this point, the impact to all child Containers is not assured yet. Please report any issue for child Containers or derivative Containers based upon this base Container image.
./run.sh
./tryJava.sh
./tryNodeJS.sh
./tryPython.sh
./tryWebSockerServer.sh
./build.sh
docker pull openkbs/jdk-mvn-py3
FROM openkbs/jdk-mvn-py3
... (then your customization Dockerfile code here)
Then, you're ready to run:
mkdir ./data
docker run -d --name my-jdk-mvn-py3 -v $PWD/data:/data -i -t openkbs/jdk-mvn-py3
Say, you will build the image "my/jdk-mvn-py3".
docker build -t my/jdk-mvn-py3 .
To run your own image, say, with some-jdk-mvn-py3:
mkdir ./data
docker run -d --name some-jdk-mvn-py3 -v $PWD/data:/data -i -t my/jdk-mvn-py3
docker exec -it some-jdk-mvn-py3 /bin/bash
To run Python code
docker run -it --rm openkbs/jdk-mvn-py3 python3 -c 'print("Hello World")'
or,
docker run -i --rm openkbs/jdk-mvn-py3 python3 < myPyScript.py
or,
mkdir ./data
echo "print('Hello World')" > ./data/myPyScript.py
docker run -it --rm --name some-jdk-mvn-py3 -v "$PWD"/data:/data openkbs/jdk-mvn-py3 python3 myPyScript.py
or,
alias dpy3='docker run --rm openkbs/jdk-mvn-py3 python3'
dpy3 -c 'print("Hello World")'
Remember, the default working directory, /data, inside the docker container -- treat is as "/". So, if you create subdirectory, "./data/workspace", in the host machine and the docker container will have it as "/data/workspace".
#!/bin/bash -x
mkdir ./data
cat >./data/HelloWorld.java <<-EOF
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
EOF
cat ./data/HelloWorld.java
alias djavac='docker run -it --rm --name some-jdk-mvn-py3 -v '$PWD'/data:/data openkbs/jdk-mvn-py3 javac'
alias djava='docker run -it --rm --name some-jdk-mvn-py3 -v '$PWD'/data:/data openkbs/jdk-mvn-py3 java'
djavac HelloWorld.java
djava HelloWorld
And, the output:
Hello, World
Hence, the alias above, "djavac" and "djava" is your docker-based "javac" and "java" commands and it will work the same way as your local installed Java's "javac" and "java" commands.
Run the NodeJS mini-server script:
./tryNodeJS.sh
Then, open web browser to go to http://0.0.0.0:3000/ to NodeJS mini-web server test.
There are various ways to run Python virtual envrionments, for example,
Add the following code to the end of ~/.bashrc
#########################################################################
#### ---- Customization for multiple virtual python environment ---- ####
#########################################################################
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
export WORKON_HOME=~/Envs
if [ ! -d $WORKON_HOME ]; then
mkdir -p $WORKON_HOME
fi
mkvirtualenv my-venv
workon my-venv
However, for larger complex projects, you might want to consider to use Docker-based IDE. For example, try the following Docker-based IDEs:
./certificates
-v `pwd`/certificates:/certificates ... (the rest parameters)
If you want to map to different directory for certificates, e.g., /home/developer/certificates, then
-v `pwd`/certificates:/home/developer/certificates -e SOURCE_CERTIFICATES_DIR=/home/developer/certificates ... (the rest parameters)
~/scripts/setup_system_certificates.sh
. Note that the script assumes the certficates are in /certificates
directory.~/scripts/setup_system_certificates.sh
will automatic copy to target directory and setup certificates for both System commands (wget, curl, etc) to use and Web Browsers'.developer@56d0c902f4ae:~$ /usr/scripts/printVersions.sh
+ echo JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
+ whereis java
java: /usr/bin/java /usr/share/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/share/man/man1/java.1.gz
+ echo
+ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.18.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.18.04, mixed mode, sharing)
+ mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/apache-maven-3.6.3
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.8.0-59-generic", arch: "amd64", family: "unix"
+ python -V
Python 2.7.17
+ python3 -V
Python 3.6.9
+ pip --version
pip 21.1.3 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
+ pip3 --version
pip 21.1.3 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
+ gradle --version
Welcome to Gradle 6.7.1!
Here are the highlights of this release:
- File system watching is ready for production use
- Declare the version of Java your build requires
- Java 15 support
For more details see https://docs.gradle.org/6.7.1/release-notes.html
------------------------------------------------------------
Gradle 6.7.1
------------------------------------------------------------
Build time: 2020-11-16 17:09:24 UTC
Revision: 2972ff02f3210d2ceed2f1ea880f026acfbab5c0
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 11.0.11 (Ubuntu 11.0.11+9-Ubuntu-0ubuntu2.18.04)
OS: Linux 5.8.0-59-generic amd64
+ npm -v
7.20.0
+ node -v
v16.4.1
+ yarn -V
yarn install v1.22.5
warning package.json: No license field
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 3.58s.
+ cat /etc/lsb-release /etc/os-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
developer@d14afe4d3b73:~$ pip freeze
appdirs==1.4.4
argon2-cffi==20.1.0
asn1crypto==0.24.0
async-generator==1.10
attrs==20.3.0
backcall==0.2.0
beautifulsoup4==4.6.0
bleach==3.2.1
certifi==2020.12.5
cffi==1.14.4
chardet==3.0.4
cloudpickle==1.6.0
cryptography==2.1.4
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
distlib==0.3.1
entrypoints==0.3
filelock==3.0.12
funcy==1.15
future==0.18.2
html5lib==0.999999999
httpie==2.3.0
hyperopt==0.2.5
idna==2.10
importlib-metadata==3.1.1
importlib-resources==3.3.0
iniconfig==1.1.1
ipaddress==1.0.23
ipykernel==5.4.2
ipython==7.16.1
ipython-genutils==0.2.0
ipywidgets==7.5.1
j2cli==0.3.10
jedi==0.17.2
Jinja2==2.11.2
joblib==0.17.0
json-lines==0.5.0
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.7
jupyter-console==6.2.0
jupyter-core==4.7.0
jupyterlab-pygments==0.1.2
keyring==10.6.0
keyrings.alt==3.0
kiwisolver==1.3.1
lxml==4.2.1
MarkupSafe==1.1.1
matplotlib==3.3.3
mistune==0.8.4
nbclient==0.5.1
nbconvert==6.0.7
nbformat==5.0.8
nest-asyncio==1.4.3
networkx==2.5
notebook==6.1.5
numexpr==2.7.1
numpy==1.19.4
olefile==0.45.1
packaging==20.7
panda==0.3.1
pandas==1.1.5
pandasql==0.7.3
pandocfilters==1.4.3
parso==0.7.1
pbr==5.5.1
pexpect==4.8.0
pickleshare==0.7.5
Pillow==8.0.1
pkgconfig==1.5.1
pluggy==0.13.1
prometheus-client==0.9.0
prompt-toolkit==3.0.8
ptyprocess==0.6.0
py==1.9.0
pycparser==2.20
pycrypto==2.6.1
Pygments==2.7.3
pygobject==3.26.1
pyLDAvis==2.1.2
pyparsing==2.4.7
pyrsistent==0.17.3
PySocks==1.7.1
pytest==6.1.2
python-apt==1.6.5+ubuntu0.5
python-dateutil==2.8.1
python-git==2018.2.1
pytz==2020.4
pyxdg==0.25
PyYAML==3.11
pyzmq==20.0.0
qtconsole==5.0.1
QtPy==1.9.0
requests==2.25.0
requests-toolbelt==0.9.1
scikit-learn==0.23.2
scipy==1.5.4
seaborn==0.11.0
SecretStorage==2.3.1
Send2Trash==1.5.0
six==1.15.0
SQLAlchemy==1.3.20
stevedore==3.3.0
tables==3.4.2
terminado==0.9.1
testpath==0.4.4
threadpoolctl==2.1.0
toml==0.10.2
tornado==6.1
tqdm==4.54.1
traitlets==4.3.3
unattended-upgrades==0.1
urllib3==1.26.2
virtualenv==20.2.2
virtualenv-clone==0.5.4
virtualenvwrapper==4.8.4
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.5.1
yml2json==1.0.1
zipp==3.4.0
docker pull openkbs/jdk-mvn-py3