Browse Source

add template

master
zeus 3 years ago
parent
commit
c399493b69
  1. 70
      install/usr/share/swarmlab.io/sec/swarmlab-sec
  2. 62
      install/usr/share/swarmlab.io/sec/swarmlab-template.sh

70
install/usr/share/swarmlab.io/sec/swarmlab-sec

@ -72,12 +72,7 @@ set -e
# #
# ############################################## # ##############################################
IMAGE_local="microservice-xelatexthesis" . $SRPATH/swarmlab-template-image
IMAGE_origin="hub.swarmlab.io:5480/xelatex-basegui"
GIT_origin="https://git.swarmlab.io:3000/swarmlab/swarmlab-microservice-example.git"
service_GUI=true
service_WEB=true
service_URL=http
DOCKERuser="docker" DOCKERuser="docker"
Wdir=${cwdir}/$IMAGE_local Wdir=${cwdir}/$IMAGE_local
@ -85,7 +80,6 @@ if [ ! -d $Wdir ]; then
mkdir -p $Wdir mkdir -p $Wdir
fi fi
# edit it - EDIT_END
APTPARAM=" --no-install-recommends " APTPARAM=" --no-install-recommends "
HYBRID_NETWORK=$IMAGE_local HYBRID_NETWORK=$IMAGE_local
@ -177,38 +171,11 @@ if [ -d "$Wdir/project" ]; then
extrapackages \ extrapackages \
/ /
# ############################### EOF
# EDIT-BEGIN
# this part must be exactly the same as that stated under create_project
# ###############################
RUN export DEBIAN_FRONTEND=noninteractive \
&& rm -rf /usr/share/doc \
&& rm -rf /usr/share/man \
&& rm -rf /usr/share/locale \
&& mkdir -p /var/run/sshd \
&& addgroup -S docker && adduser -S docker -G docker \
&& echo 'root:$ROOT_PASSWORD' | chpasswd \
&& echo "export VISIBLE=now" >> /etc/profile \
&& mkdir -p /home/docker/project \
&& mkdir -p /etc/opt \
&& echo "docker:docker" | chpasswd \
&& echo "StrictHostKeyChecking no" > \${SSHDIR}/config \
&& cat \${SSHDIR}/*.pub >> \${SSHDIR}/authorized_keys \
&& chmod -R 600 \${SSHDIR}/* \
&& chown -R \${USER1}:\${USER1} \${SSHDIR}
COPY .vimrc /home/docker
RUN /setup.sh
EXPOSE 8080
# ############################### cat $Wdir/Dockerfile.tmp >> $Wdir/Dockerfile
# EDIT-END
# ###############################
EOF
fi fi
else else
echo "" echo ""
@ -275,38 +242,11 @@ if [ "$Wdir" == "$HOME" ]; then
extrapackages \ extrapackages \
/ /
# ############################### EOF
# EDIT-BEGIN
# this part must be exactly the same as that stated under create_dockerfile
# ###############################
RUN export DEBIAN_FRONTEND=noninteractive \
&& addgroup -S docker && adduser -S docker -G docker \
&& rm -rf /usr/share/doc \
&& rm -rf /usr/share/man \
&& rm -rf /usr/share/locale \
&& mkdir -p /var/run/sshd \
&& echo 'root:$ROOT_PASSWORD' | chpasswd \
&& echo "export VISIBLE=now" >> /etc/profile \
&& mkdir -p /home/docker/project \
&& mkdir -p /etc/opt \
&& echo "docker:docker" | chpasswd \
&& echo "StrictHostKeyChecking no" > \${SSHDIR}/config \
&& cat \${SSHDIR}/*.pub >> \${SSHDIR}/authorized_keys \
&& chmod -R 600 \${SSHDIR}/* \
&& chown -R \${USER1}:\${USER1} \${SSHDIR}
COPY .vimrc /home/docker
RUN /setup.sh
EXPOSE 8080 cat $Wdir/Dockerfile.tmp >> $Wdir/Dockerfile
# ###############################
# EDIT-END
# ###############################
EOF
fi fi
# you do not need to edit it - BEGIN # you do not need to edit it - BEGIN

62
install/usr/share/swarmlab.io/sec/swarmlab-template.sh

@ -0,0 +1,62 @@
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
cat << EOF > $SRPATH/swarmlab-template-image
IMAGE_local="microservice-xelatexthesis"
IMAGE_origin="hub.swarmlab.io:5480/xelatex-basegui"
GIT_origin="https://git.swarmlab.io:3000/swarmlab/swarmlab-microservice-example.git"
service_GUI=true
service_WEB=true
service_URL=http
EOF
cat << EOF >> $Wdir/Dockerfile.tmp
RUN export DEBIAN_FRONTEND=noninteractive \
&& rm -rf /usr/share/doc \
&& rm -rf /usr/share/man \
&& rm -rf /usr/share/locale \
&& mkdir -p /var/run/sshd \
&& addgroup -S docker && adduser -S docker -G docker \
&& echo 'root:$ROOT_PASSWORD' | chpasswd \
&& echo "export VISIBLE=now" >> /etc/profile \
&& mkdir -p /home/docker/project \
&& mkdir -p /etc/opt \
&& echo "docker:docker" | chpasswd \
&& echo "StrictHostKeyChecking no" > \${SSHDIR}/config \
&& cat \${SSHDIR}/*.pub >> \${SSHDIR}/authorized_keys \
&& chmod -R 600 \${SSHDIR}/* \
&& chown -R \${USER1}:\${USER1} \${SSHDIR}
COPY .vimrc /home/docker
RUN /setup.sh
EXPOSE 8080
EOF
Loading…
Cancel
Save