Build Java Docker Image from CentOS: Difference between revisions
Jump to navigation
Jump to search
(4 intermediate revisions by the same user not shown) | |||
Line 48: | Line 48: | ||
yum -y install nano && | yum -y install nano && | ||
yum -y install wget && | yum -y install wget && | ||
yum -y install unzip && | |||
yum -y install java-1.8.0-openjdk && | yum -y install java-1.8.0-openjdk && | ||
Line 54: | Line 55: | ||
wget -q http://cdn.chorke.org/soft/comn/maven/apache-maven-3.3.9.zip -P /chorke/cli/ && | wget -q http://cdn.chorke.org/soft/comn/maven/apache-maven-3.3.9.zip -P /chorke/cli/ && | ||
wget -q http://cdn.chorke.org/soft/comn/ant/apache-ant-1.9.9.zip -P /chorke/cli/ && | wget -q http://cdn.chorke.org/soft/comn/ant/apache-ant-1.9.9.zip -P /chorke/cli/ && | ||
unzip /chorke/cli/apache-maven-3.3.9.zip -d /chorke/cli/ && | unzip -qq /chorke/cli/apache-maven-3.3.9.zip -d /chorke/cli/ && | ||
unzip /chorke/cli/apache-ant-1.9.9.zip -d /chorke/cli/ && | unzip -qq /chorke/cli/apache-ant-1.9.9.zip -d /chorke/cli/ && | ||
rm -rf /chorke/cli/apache-maven-3.3.9.zip && | rm -rf /chorke/cli/apache-maven-3.3.9.zip && | ||
rm -rf /chorke/cli/apache-ant-1.9.9.zip && | rm -rf /chorke/cli/apache-ant-1.9.9.zip && | ||
Line 84: | Line 85: | ||
echo '' >> /etc/bash.bashrc && | echo '' >> /etc/bash.bashrc && | ||
echo '' >> /etc/bash.bashrc && | echo '' >> /etc/bash.bashrc && | ||
Line 103: | Line 91: | ||
mv /assets/.ssh $HOME && | mv /assets/.ssh $HOME && | ||
mv /assets/.chorke $HOME && | mv /assets/.chorke $HOME && | ||
# install startup script for container | |||
mv /assets/startup.sh /usr/sbin/startup.sh && | |||
chmod +x /usr/sbin/startup.sh && | |||
# remove assets | |||
rm -r /assets/ | |||
# download default maven plugins and dependencies | # download default maven plugins and dependencies | ||
wget -q http://cdn.chorke.org/soft/comn/repository/m2_repository_20180201.zip -P $HOME/.m2/ && | 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/ && | unzip -qq $HOME/.m2/m2_repository_20180201.zip -d $HOME/.m2/ && | ||
rm -rf $HOME/.m2/m2_repository_20180201.zip && | rm -rf $HOME/.m2/m2_repository_20180201.zip && | ||
# | # 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/ && | |||
exit $? | exit $? | ||
Line 143: | Line 143: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
docker build -t 'chorke/ebis' -f ./Dockerfile ./ | docker build -t 'chorke/ebis' -f ./Dockerfile ./ | ||
docker build --rm -t 'chorke/ebis' -f ./Dockerfile ./ | |||
docker run --name='initd' -d -p 2223:22 -p 8080:80 chorke/ebis | docker run --name='initd' -d -p 2223:22 -p 8080:80 chorke/ebis | ||
docker run --name='ebis' -it centos:7 bash | docker run --name='ebis' -it centos:7 bash | ||
docker rmi $(docker images -qa -f 'dangling=true') | |||
docker rm initd && docker rmi chorke/ebis | docker rm initd && docker rmi chorke/ebis | ||
docker history chorke/ebis | docker history chorke/ebis | ||
Line 169: | Line 171: | ||
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 00:04, 21 May 2018
Dockerfile
./Dockerfile
FROM centos:7
MAINTAINER Chorke, Inc.<[email protected]>
ADD assets /assets
RUN /assets/setup.sh
EXPOSE 22
EXPOSE 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 0.0.00
@since 0.0.00
'
# disable fastest mirror
rm -rf /etc/yum/pluginconf.d/fastestmirror.conf &&
yum clean all && rm -rf /var/cache/yum &&
# install openssh
yum -y update &&
yum -y install openssh-server &&
yum -y install openssh-clients &&
mkdir /var/run/sshd &&
echo 'root:admin' | chpasswd &&
sed -i 's/#PermitRootLogin yes/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
yum -y install zip &&
yum -y install git &&
yum -y install nano &&
yum -y install wget &&
yum -y install unzip &&
yum -y install java-1.8.0-openjdk &&
# 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 /chorke/cli/ &&
wget -q http://cdn.chorke.org/soft/comn/ant/apache-ant-1.9.9.zip -P /chorke/cli/ &&
unzip -qq /chorke/cli/apache-maven-3.3.9.zip -d /chorke/cli/ &&
unzip -qq /chorke/cli/apache-ant-1.9.9.zip -d /chorke/cli/ &&
rm -rf /chorke/cli/apache-maven-3.3.9.zip &&
rm -rf /chorke/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=/chorke/cli/apache-ant-1.9.9' >> /etc/bash.bashrc &&
echo 'export M2_HOME=/chorke/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=/chorke/dev/jee/cki_workspaces' >> /etc/bash.bashrc &&
echo 'export EBIS_HOME=/chorke/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 &&
# copy default home config
mv /assets/.m2 $HOME &&
mv /assets/.ssh $HOME &&
mv /assets/.chorke $HOME &&
# install startup script for container
mv /assets/startup.sh /usr/sbin/startup.sh &&
chmod +x /usr/sbin/startup.sh &&
# remove assets
rm -r /assets/
# download default maven plugins and dependencies
wget -q http://cdn.chorke.org/soft/comn/repository/m2_repository_20180201.zip -P $HOME/.m2/ &&
unzip -qq $HOME/.m2/m2_repository_20180201.zip -d $HOME/.m2/ &&
rm -rf $HOME/.m2/m2_repository_20180201.zip &&
# 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/ &&
exit $?
Startup Script
./assets/startup.sh
#!/bin/bash
: '
@author "Chorke, Inc."<[email protected]>
@web http://chorke.org
@vendor Chorke, Inc.
@version 0.0.00
@since 0.0.00
'
# env for chorke workspaces and application
export CKI_WORKSPACES=/chorke/dev/jee/cki_workspaces &&
export EBIS_HOME=/chorke/pro/ebis &&
export PATH=$EBIS_HOME/bin:$PATH
Good to Know
docker build -t 'chorke/ebis' -f ./Dockerfile ./
docker build --rm -t 'chorke/ebis' -f ./Dockerfile ./
docker run --name='initd' -d -p 2223:22 -p 8080:80 chorke/ebis
docker run --name='ebis' -it centos:7 bash
docker rmi $(docker images -qa -f 'dangling=true')
docker rm initd && docker rmi chorke/ebis
docker history chorke/ebis
service status ssh
service --status-all
printenv
# disable fastest mirror
sed -ie 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.conf &&
rm -rf /etc/yum/pluginconf.d/fastestmirror.confe &&
rm -rf /var/cache/yum &&
# yum clean all &&
yum -y install git
yum -y install openjdk-8-jdk
yum -y install zip
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/