Build Java Docker Image from Ubuntu: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(34 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
MAINTAINER Chorke, Inc.<[email protected]> | MAINTAINER Chorke, Inc.<[email protected]> | ||
ENV container=docker | |||
ENV DEBIAN_FRONTEND=noninteractive | |||
EXPOSE 22 | ADD assets /root/.docker | ||
RUN /root/.docker/setup.sh | |||
EXPOSE 22 8080 | |||
CMD /usr/sbin/startup.sh && | CMD /usr/sbin/startup.sh && /usr/sbin/sshd -D | ||
/usr/sbin/sshd -D | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Setup Script == | == Setup Script == | ||
<code>./assets/setup.sh</code> | <code>./assets/setup.sh</code> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
#!/bin/bash | #!/bin/bash | ||
: ' | : ' | ||
Line 23: | Line 23: | ||
@web http://chorke.org | @web http://chorke.org | ||
@vendor Chorke, Inc. | @vendor Chorke, Inc. | ||
@version | @version 1.0.00.GA | ||
@since | @since 1.0.00.GA | ||
' | ' | ||
# apt-get in not interactive mode | # apt-get in not interactive mode | ||
export DEBIAN_FRONTEND=noninteractive | export DEBIAN_FRONTEND=noninteractive | ||
export CKI_WORKSPACES=/cki/dev/jee/cki_workspaces | |||
# install openssh | # install openssh | ||
apt update && | apt-get update && | ||
apt -y install openssh-server && | apt-get -y install openssh-server && | ||
apt -y install openssh-client && | apt-get -y install openssh-client && | ||
# config openssh | |||
mkdir /var/run/sshd && | mkdir /var/run/sshd && | ||
echo 'root:admin' | chpasswd && | echo 'root:admin' | chpasswd && | ||
Line 42: | Line 45: | ||
# install zip, git and openjdk | # install zip, git and openjdk | ||
apt -y install zip && | apt-get -y install zip && | ||
apt -y install git && | apt-get -y install git && | ||
apt -y install openjdk-8-jdk && | apt-get -y install nano && | ||
apt-get -y install openjdk-8-jdk && | |||
apt-get clean && | |||
# download, install apache maven and ant from chorke development network | |||
wget -q http://cdn.chorke.org/soft/comn/maven/apache-maven-3.3.9.zip -P /opt/cli/ && | |||
wget -q http://cdn.chorke.org/soft/comn/ant/apache-ant-1.9.9.zip -P /opt/cli/ && | |||
unzip /opt/cli/apache-maven-3.3.9.zip -d /opt/cli/ && | |||
unzip /opt/cli/apache-ant-1.9.9.zip -d /opt/cli/ && | |||
rm -rf /opt/cli/apache-maven-3.3.9.zip && | |||
rm -rf /opt/cli/apache-ant-1.9.9.zip && | |||
Line 51: | Line 65: | ||
echo '# env for chorke workspaces and application' >> /etc/bash.bashrc && | echo '# env for chorke workspaces and application' >> /etc/bash.bashrc && | ||
echo 'export TMPDIR=/tmp' >> /etc/bash.bashrc && | echo 'export TMPDIR=/tmp' >> /etc/bash.bashrc && | ||
echo 'export ANT_HOME=/ | echo 'export ANT_HOME=/opt/cli/apache-ant-1.9.9' >> /etc/bash.bashrc && | ||
echo 'export M2_HOME=/ | echo 'export M2_HOME=/opt/cli/apache-maven-3.3.9' >> /etc/bash.bashrc && | ||
echo 'export JRE_HOME=$(dirname $(dirname $(readlink -e $(which java))))' >> /etc/bash.bashrc && | echo 'export JRE_HOME=$(dirname $(dirname $(readlink -e $(which java))))' >> /etc/bash.bashrc && | ||
echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -e $(which javac))))' >> /etc/bash.bashrc && | echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -e $(which javac))))' >> /etc/bash.bashrc && | ||
echo 'export CKI_WORKSPACES=/ | echo 'export CKI_WORKSPACES=/cki/dev/jee/cki_workspaces' >> /etc/bash.bashrc && | ||
echo 'export EBIS_HOME=/ | echo 'export EBIS_HOME=/cki/pro/ebis' >> /etc/bash.bashrc && | ||
Line 62: | Line 76: | ||
echo '' >> /etc/bash.bashrc && | echo '' >> /etc/bash.bashrc && | ||
echo '# add executable path' >> /etc/bash.bashrc && | echo '# add executable path' >> /etc/bash.bashrc && | ||
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/bash.bashrc && | |||
echo 'export PATH=$JRE_HOME/bin:$PATH' >> /etc/bash.bashrc && | echo 'export PATH=$JRE_HOME/bin:$PATH' >> /etc/bash.bashrc && | ||
echo 'export PATH=$ANT_HOME/bin:$PATH' >> /etc/bash.bashrc && | echo 'export PATH=$ANT_HOME/bin:$PATH' >> /etc/bash.bashrc && | ||
echo 'export PATH=$M2_HOME/bin:$PATH' >> /etc/bash.bashrc && | echo 'export PATH=$M2_HOME/bin:$PATH' >> /etc/bash.bashrc && | ||
Line 71: | Line 85: | ||
echo '' >> /etc/bash.bashrc && | echo '' >> /etc/bash.bashrc && | ||
echo '' >> /etc/bash.bashrc && | echo '' >> /etc/bash.bashrc && | ||
# clone init_workspace from bit.chorke.org | |||
mkdir -p $CKI_WORKSPACES/init_workspace && | |||
git clone bit.chorke.org:chorkeorg/chorke-init-filter.git $CKI_WORKSPACES/init_workspace/chorke-init-filter/ && | |||
git clone bit.chorke.org:chorkeorg/chorke-init-static.git $CKI_WORKSPACES/init_workspace/chorke-init-static/ && | |||
git clone bit.chorke.org:chorkeorg/chorke-init-launch.git $CKI_WORKSPACES/init_workspace/chorke-init-launch/ && | |||
# clone make_workspace from bit.chorke.org | |||
mkdir -p $CKI_WORKSPACES/make_workspace && | |||
git clone bit.chorke.org:chorkeorg/chorke-make-filter.git $CKI_WORKSPACES/make_workspace/chorke-make-filter/ && | |||
git clone bit.chorke.org:chorkeorg/chorke-make-init.d.git $CKI_WORKSPACES/make_workspace/chorke-make-init.d/ && | |||
# copy default home config | |||
mv /root/.docker/.m2 $HOME && | |||
mv /root/.docker/.ssh $HOME && | |||
mv /root/.docker/.chorke $HOME && | |||
# download default maven plugins and dependencies | |||
wget -q http://cdn.chorke.org/soft/comn/repository/m2_repository_20180201.zip -P $HOME/.m2/ && | |||
unzip $HOME/.m2/m2_repository_20180201.zip -d $HOME/.m2/ && | |||
rm -rf $HOME/.m2/m2_repository_20180201.zip && | |||
# install startup script for container | # install startup script for container | ||
mv / | mv /root/.docker/startup.sh /usr/sbin/startup.sh && | ||
chmod +x /usr/sbin/startup.sh && | chmod +x /usr/sbin/startup.sh && | ||
# safe exit | |||
exit $? | exit $? | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 89: | Line 123: | ||
== Startup Script == | == Startup Script == | ||
<code>./assets/startup.sh</code> | <code>./assets/startup.sh</code> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
#!/bin/bash | #!/bin/bash | ||
: ' | : ' | ||
Line 95: | Line 129: | ||
@web http://chorke.org | @web http://chorke.org | ||
@vendor Chorke, Inc. | @vendor Chorke, Inc. | ||
@version | @version 1.0.00.GA | ||
@since | @since 1.0.00.GA | ||
' | ' | ||
# env for chorke workspaces and application | # env for chorke workspaces and application | ||
export CKI_WORKSPACES=/ | export CKI_WORKSPACES=/cki/dev/jee/cki_workspaces && | ||
export EBIS_HOME=/ | export EBIS_HOME=/cki/pro/ebis && | ||
export PATH=$EBIS_HOME/bin:$PATH | export PATH=$EBIS_HOME/bin:$PATH | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 107: | Line 141: | ||
== Good to Know == | == Good to Know == | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
docker build -t 'chorke/ | docker build --rm -t 'chorke/init:1.0.00.GA' -f ./Dockerfile ./ | ||
docker | docker build --rm -t 'chorke/init:1.0.00.GA' ./ | ||
docker rm initd && docker rmi chorke/ | docker build --rm -t 'chorke/init' ./ | ||
docker history chorke/ | |||
docker rmi $(docker images -qa -f 'dangling=true') | |||
docker rm $(docker ps --all -q -f status=dead) | |||
docker rm initd && docker rmi chorke/init | |||
docker history chorke/init | |||
service status | docker run --name='initd' -d -p 2223:22 -p 8080:80 chorke/init | ||
docker run --name='initd' -it chorke/init bash | |||
docker exec -it initd /bin/bash | |||
docker exec -it initd bash | |||
# docker attach initd | |||
service ssh status | |||
service --status-all | service --status-all | ||
service apache2 status | |||
printenv | printenv | ||
apt -y install git | apt-get -y install git | ||
apt -y install openjdk-8-jdk | apt-get -y install zip | ||
apt-get -y install apache2 | |||
apt-get -y install openjdk-8-jdk | |||
echo 'ServerName localhost' >> /etc/apache2/conf-enabled/fqdn.conf | |||
echo 'ServerName localhost' >> /etc/apache2/conf-available/fqdn.conf | |||
apachectl -t | |||
wget http://cdn.chorke.org/soft/comn/ant/apache-ant-1.9.9.zip && | wget http://cdn.chorke.org/soft/comn/ant/apache-ant-1.9.9.zip && | ||
Line 126: | Line 177: | ||
unzip apache-maven-3.3.9.zip -d cli/ | unzip apache-maven-3.3.9.zip -d cli/ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== References == | |||
* [https://github.com/zanaca/docker-dns/blob/master/Dockerfile Alpine SSH Config] | |||
* [https://github.com/sameersbn/docker-bind Webmin installation] | |||
* [https://docs.docker.com/config/containers/multi-service_container/ Run multiple services] |
Latest revision as of 23:11, 23 May 2018
Dockerfile
./Dockerfile
FROM ubuntu:16.04
MAINTAINER Chorke, Inc.<[email protected]>
ENV container=docker
ENV DEBIAN_FRONTEND=noninteractive
ADD assets /root/.docker
RUN /root/.docker/setup.sh
EXPOSE 22 8080
CMD /usr/sbin/startup.sh && /usr/sbin/sshd -D
Setup Script
./assets/setup.sh
#!/bin/bash
: '
@author "Chorke, Inc."<[email protected]>
@web http://chorke.org
@vendor Chorke, Inc.
@version 1.0.00.GA
@since 1.0.00.GA
'
# apt-get in not interactive mode
export DEBIAN_FRONTEND=noninteractive
export CKI_WORKSPACES=/cki/dev/jee/cki_workspaces
# install openssh
apt-get update &&
apt-get -y install openssh-server &&
apt-get -y install openssh-client &&
# config openssh
mkdir /var/run/sshd &&
echo 'root:admin' | chpasswd &&
sed -i 's/^PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config &&
sed -i 's/session\s*required\s*pam_loginuid.so/session optional pam_loginuid.so/g' /etc/pam.d/sshd &&
echo 'export VISIBLE=now' >> /etc/profile &&
# install zip, git and openjdk
apt-get -y install zip &&
apt-get -y install git &&
apt-get -y install nano &&
apt-get -y install openjdk-8-jdk &&
apt-get clean &&
# download, install apache maven and ant from chorke development network
wget -q http://cdn.chorke.org/soft/comn/maven/apache-maven-3.3.9.zip -P /opt/cli/ &&
wget -q http://cdn.chorke.org/soft/comn/ant/apache-ant-1.9.9.zip -P /opt/cli/ &&
unzip /opt/cli/apache-maven-3.3.9.zip -d /opt/cli/ &&
unzip /opt/cli/apache-ant-1.9.9.zip -d /opt/cli/ &&
rm -rf /opt/cli/apache-maven-3.3.9.zip &&
rm -rf /opt/cli/apache-ant-1.9.9.zip &&
echo '' >> /etc/bash.bashrc &&
echo '' >> /etc/bash.bashrc &&
echo '# env for chorke workspaces and application' >> /etc/bash.bashrc &&
echo 'export TMPDIR=/tmp' >> /etc/bash.bashrc &&
echo 'export ANT_HOME=/opt/cli/apache-ant-1.9.9' >> /etc/bash.bashrc &&
echo 'export M2_HOME=/opt/cli/apache-maven-3.3.9' >> /etc/bash.bashrc &&
echo 'export JRE_HOME=$(dirname $(dirname $(readlink -e $(which java))))' >> /etc/bash.bashrc &&
echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -e $(which javac))))' >> /etc/bash.bashrc &&
echo 'export CKI_WORKSPACES=/cki/dev/jee/cki_workspaces' >> /etc/bash.bashrc &&
echo 'export EBIS_HOME=/cki/pro/ebis' >> /etc/bash.bashrc &&
echo '' >> /etc/bash.bashrc &&
echo '' >> /etc/bash.bashrc &&
echo '# add executable path' >> /etc/bash.bashrc &&
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/bash.bashrc &&
echo 'export PATH=$JRE_HOME/bin:$PATH' >> /etc/bash.bashrc &&
echo 'export PATH=$ANT_HOME/bin:$PATH' >> /etc/bash.bashrc &&
echo 'export PATH=$M2_HOME/bin:$PATH' >> /etc/bash.bashrc &&
echo 'export PATH=$EBIS_HOME/bin:$PATH' >> /etc/bash.bashrc &&
echo '' >> /etc/bash.bashrc &&
echo '' >> /etc/bash.bashrc &&
# clone init_workspace from bit.chorke.org
mkdir -p $CKI_WORKSPACES/init_workspace &&
git clone bit.chorke.org:chorkeorg/chorke-init-filter.git $CKI_WORKSPACES/init_workspace/chorke-init-filter/ &&
git clone bit.chorke.org:chorkeorg/chorke-init-static.git $CKI_WORKSPACES/init_workspace/chorke-init-static/ &&
git clone bit.chorke.org:chorkeorg/chorke-init-launch.git $CKI_WORKSPACES/init_workspace/chorke-init-launch/ &&
# clone make_workspace from bit.chorke.org
mkdir -p $CKI_WORKSPACES/make_workspace &&
git clone bit.chorke.org:chorkeorg/chorke-make-filter.git $CKI_WORKSPACES/make_workspace/chorke-make-filter/ &&
git clone bit.chorke.org:chorkeorg/chorke-make-init.d.git $CKI_WORKSPACES/make_workspace/chorke-make-init.d/ &&
# copy default home config
mv /root/.docker/.m2 $HOME &&
mv /root/.docker/.ssh $HOME &&
mv /root/.docker/.chorke $HOME &&
# download default maven plugins and dependencies
wget -q http://cdn.chorke.org/soft/comn/repository/m2_repository_20180201.zip -P $HOME/.m2/ &&
unzip $HOME/.m2/m2_repository_20180201.zip -d $HOME/.m2/ &&
rm -rf $HOME/.m2/m2_repository_20180201.zip &&
# install startup script for container
mv /root/.docker/startup.sh /usr/sbin/startup.sh &&
chmod +x /usr/sbin/startup.sh &&
# safe exit
exit $?
Startup Script
./assets/startup.sh
#!/bin/bash
: '
@author "Chorke, Inc."<[email protected]>
@web http://chorke.org
@vendor Chorke, Inc.
@version 1.0.00.GA
@since 1.0.00.GA
'
# env for chorke workspaces and application
export CKI_WORKSPACES=/cki/dev/jee/cki_workspaces &&
export EBIS_HOME=/cki/pro/ebis &&
export PATH=$EBIS_HOME/bin:$PATH
Good to Know
docker build --rm -t 'chorke/init:1.0.00.GA' -f ./Dockerfile ./
docker build --rm -t 'chorke/init:1.0.00.GA' ./
docker build --rm -t 'chorke/init' ./
docker rmi $(docker images -qa -f 'dangling=true')
docker rm $(docker ps --all -q -f status=dead)
docker rm initd && docker rmi chorke/init
docker history chorke/init
docker run --name='initd' -d -p 2223:22 -p 8080:80 chorke/init
docker run --name='initd' -it chorke/init bash
docker exec -it initd /bin/bash
docker exec -it initd bash
# docker attach initd
service ssh status
service --status-all
service apache2 status
printenv
apt-get -y install git
apt-get -y install zip
apt-get -y install apache2
apt-get -y install openjdk-8-jdk
echo 'ServerName localhost' >> /etc/apache2/conf-enabled/fqdn.conf
echo 'ServerName localhost' >> /etc/apache2/conf-available/fqdn.conf
apachectl -t
wget http://cdn.chorke.org/soft/comn/ant/apache-ant-1.9.9.zip &&
unzip apache-ant-1.9.9.zip /opt/cli/
wget http://cdn.chorke.org/soft/comn/maven/apache-maven-3.3.9.zip &&
unzip apache-maven-3.3.9.zip -d cli/