Added files for building deploy image
This commit is contained in:
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk --update --no-cache add git openssh-client jq
|
||||
|
||||
COPY config /root/.ssh/
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
COPY deploy.sh /deploy.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
8
config
Normal file
8
config
Normal file
@@ -0,0 +1,8 @@
|
||||
Host GIT_REPOSITORY
|
||||
User git
|
||||
Port PORT
|
||||
Hostname HOST
|
||||
PreferredAuthentications publickey
|
||||
IdentityFile /root/.ssh/id_rsa
|
||||
IdentitiesOnly yes
|
||||
StrictHostKeyChecking no
|
27
deploy.sh
27
deploy.sh
@@ -4,14 +4,17 @@ toUpperCase() {
|
||||
echo "$*" | tr '[:lower:]' '[:upper:]';
|
||||
}
|
||||
GIT_REPO=$GIT_REPO
|
||||
ORGANIZTAION=$ORGANIZATION
|
||||
ORGANIZATION=$ORGANIZATION
|
||||
|
||||
if [ "$ORGANIZATION" == "" ]; then
|
||||
ORGANIZATION=format
|
||||
fi
|
||||
|
||||
PUBLIC_PROXY=$(toUpperCase $PUBLIC_PROXY)
|
||||
SMARTHOST_PROXY=$(toUpperCase $SMARTHOST_PROXY)
|
||||
WIREGUARD=$(toUpperCase $WIREGUARD)
|
||||
OPENVPN=$(toUpperCase $OPENVPN)
|
||||
|
||||
DEPLOY_KEY=$DEPLOY_KEY
|
||||
SERVICE_DIR=$SERVICE_DIR
|
||||
PROXY_DIR=$PROXY_DIR
|
||||
PROXY_LOG_DIR=$PROXY_LOG_DIR
|
||||
@@ -31,7 +34,7 @@ fi
|
||||
for i in $(echo $PROXY_TYPE); do
|
||||
|
||||
# Clone source files from git repository
|
||||
git clone $GIT_REPO/$ORGANIZATION/$i.git
|
||||
git clone ssh://$GIT_REPO/$ORGANIZATION/$i.git /tmp/
|
||||
|
||||
#if [ "$i" == "public-proxy" ] ; then
|
||||
|
||||
@@ -42,20 +45,21 @@ for i in $(echo $PROXY_TYPE); do
|
||||
|
||||
if [ "$SERVICE_DIR" == "" ] ; then
|
||||
SERVICE_DIR="/etc/user/config/services";
|
||||
mkdir -p $SERVICE_DIR;
|
||||
fi
|
||||
|
||||
cp -av /tmp/$REPOSITORY/$i/service_files/ $SERVICE_DIR/
|
||||
cp -av /tmp/$REPOSITORY/$i/*.json $SERVICE_DIR/
|
||||
|
||||
# CREATE FILESYSTEM ACCESS FOR SERVICES
|
||||
|
||||
if [ "$PROXY_DIR" == "" ] ; then
|
||||
$PUBLIC_PROXY_DIR="/etc/system/config/$i";
|
||||
$PROXY_DIR="/etc/system/config/$i";
|
||||
else
|
||||
$PUBLIC_PROXY_DIR="$PROXY_DIR/$i"
|
||||
$PROXY_DIR="$PROXY_DIR/$i"
|
||||
fi
|
||||
|
||||
mkdir -p $PUBLIC_PROXY_DIR/loadbalancer;
|
||||
mkdir -p $PUBLIC_PROXY_DIR/backend;
|
||||
mkdir -p $PROXY_DIR/loadbalancer;
|
||||
mkdir -p PROXY_DIR/backend;
|
||||
|
||||
if [ "$PROXY_LOG_DIR" == "" ] ; then
|
||||
$PROXY_LOG_DIR="/etc/system/log/$i" ;
|
||||
@@ -70,8 +74,8 @@ for i in $(echo $PROXY_TYPE); do
|
||||
|
||||
# CREATE PROXY SCHEDULER SERVICE
|
||||
|
||||
# CHECK proxy.json exists
|
||||
SOURCE=$(cat /tmp/$REPOSITORY/$i/proxy.json);
|
||||
# CHECK prox config file exists
|
||||
SOURCE=$(cat /tmp/$REPOSITORY/$i/proxy_config);
|
||||
TARGET=$(cat $PUBLIC_PROXY_DIR/proxy.json | tail -n+2);
|
||||
TMP_FILE=/tmp/proxy.json
|
||||
{
|
||||
@@ -101,7 +105,7 @@ for i in $(echo $PROXY_TYPE); do
|
||||
|
||||
# COPY PROXY DNS FILES
|
||||
|
||||
git clone $GIT_REPO/$ORGANIZATION/proxy-dns.git
|
||||
git clone ssh://$GIT_REPO/$ORGANIZATION/proxy-dns.git
|
||||
|
||||
if [ "$DNS_DIR" == "" ] ; then
|
||||
$DNS_DIR="/etc/system/data/proxy-dns";
|
||||
@@ -112,3 +116,4 @@ for i in $(echo $PROXY_TYPE); do
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
41
entrypoint.sh
Executable file
41
entrypoint.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
GIT_REPOSITORY=$GIT_REPOSITORY
|
||||
HOST=$HOST
|
||||
PORT=$PORT
|
||||
cd /root
|
||||
|
||||
if [ "$PORT" == "" ]; then
|
||||
PORT=20202
|
||||
fi
|
||||
|
||||
if [ "$GIT_REPOSITORY" == "" ]; then
|
||||
GIT_REPOSITORY=git.format.hu
|
||||
fi
|
||||
|
||||
if [ "$HOST" == "" ]; then
|
||||
HOST=git.format.hu
|
||||
fi
|
||||
|
||||
sed -i "s/GIT_REPOSITORY/$GIT_REPOSITORY/g" /root/.ssh/config;
|
||||
sed -i "s/HOST/$HOST/g" /root/.ssh/config;
|
||||
sed -i "s/PORT/$PORT/g" /root/.ssh/config;
|
||||
|
||||
# Check git repository permissions"
|
||||
|
||||
if [[ "$PUBLIC_PROXY" == "YES" || "$PUBLIC_PROXY" == "TRUE" ]]; then
|
||||
PROXY_TYPE=public-proxy;
|
||||
fi
|
||||
|
||||
if [[ "$SMARTHOST_PROXY" == "YES" || "$SMARTHOST_PROXY" == "TRUE" ]]; then
|
||||
PROXY_TYPE=smarthost-proxy" "$PROXY_TYPE;
|
||||
fi
|
||||
|
||||
if [ "$PROXY_TYPE" == "" ] ; then
|
||||
echo "No proxy type deployment defined, exiting."
|
||||
exit;
|
||||
fi
|
||||
|
||||
sh /deploy.sh
|
||||
|
||||
echo "Successfully deployed $PUBLIC_PROXY $SMARTHOST_PROXY"
|
Reference in New Issue
Block a user