mirror of
https://github.com/coderofsalvation/podi.git
synced 2025-12-16 11:57:45 +01:00
work in progress [might break]
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
FROM alpine:3.1
|
FROM alpine:3.9
|
||||||
|
|
||||||
RUN apk update \
|
RUN apk update \
|
||||||
&& apk add openssh git socat\
|
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
|
||||||
|
&& apk update \
|
||||||
|
&& apk add openssh git socat \
|
||||||
&& addgroup -S git && adduser -D -S git -G git -s /bin/sh \
|
&& addgroup -S git && adduser -D -S git -G git -s /bin/sh \
|
||||||
&& mkdir -p /home/git/.ssh \
|
&& mkdir -p /home/git/.ssh \
|
||||||
&& chmod 0700 /home/git/.ssh \
|
&& chmod 0700 /home/git/.ssh \
|
||||||
|
|||||||
12
podi
12
podi
@@ -27,13 +27,6 @@ foreach() { local err=0; local args="$1";
|
|||||||
for j in $args; do "$@" "$j" || err=1; done
|
for j in $args; do "$@" "$j" || err=1; done
|
||||||
test $err = 1 && return 1 || return 0
|
test $err = 1 && return 1 || return 0
|
||||||
}
|
}
|
||||||
run_yaml() { awk '
|
|
||||||
BEGIN{ file=""; buffer="" }
|
|
||||||
/^[a-zA-Z0-9_]+: |-/ { gsub(":","",$1); file=$1 ; buffer = "" }
|
|
||||||
/ .*/ { gsub(" ","",$0); buffer=buffer$0"\n" }
|
|
||||||
/^$/ { print "writing "file; print buffer > file }
|
|
||||||
' $1
|
|
||||||
}
|
|
||||||
trigger() { printf "$C_NORMAL [$C_CYAN✓$C_NORMAL] $C_BOLD%s$C_NORMAL\n" "$1"
|
trigger() { printf "$C_NORMAL [$C_CYAN✓$C_NORMAL] $C_BOLD%s$C_NORMAL\n" "$1"
|
||||||
local cmd=$1; shift
|
local cmd=$1; shift
|
||||||
local actions="$(eval echo \$on_$cmd)"
|
local actions="$(eval echo \$on_$cmd)"
|
||||||
@@ -88,7 +81,6 @@ hello(){
|
|||||||
\e[38;5;201m 88b, ,a8" "8a, ,a8" "8a, ,d88 88
|
\e[38;5;201m 88b, ,a8" "8a, ,a8" "8a, ,d88 88
|
||||||
\e[38;5;201m 88`YbbdP"` `"YbbdP"` `"8bbdP"Y8 88
|
\e[38;5;201m 88`YbbdP"` `"YbbdP"` `"8bbdP"Y8 88
|
||||||
\e[38;5;205m 88
|
\e[38;5;205m 88
|
||||||
\e[38;5;207m 88
|
|
||||||
\e[0m'
|
\e[0m'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +101,7 @@ init_localhost(){
|
|||||||
silent recipe $runtime && . .pod/$runtime
|
silent recipe $runtime && . .pod/$runtime
|
||||||
init_runtime
|
init_runtime
|
||||||
}
|
}
|
||||||
test -d .pod && for i in .pod/* ; do . $i; done
|
test -d .pod && for i in .pod/*; do . $i; done
|
||||||
test -f podi || cp $0 .
|
test -f podi || cp $0 .
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,7 +183,7 @@ init_remotes(){
|
|||||||
|
|
||||||
usage(){
|
usage(){
|
||||||
init_dirs
|
init_dirs
|
||||||
test -d .git && silent grep "bare = true" .git/config && error "dont use podi on production server"
|
test -d .git && silent grep "bare = true" .git/config && { echo "Usage: ./podi start\n./podi stop"; exit 0; }
|
||||||
echo "usage: "
|
echo "usage: "
|
||||||
awk '/[a-zA-Z0-9_]+\(\){ #/ {
|
awk '/[a-zA-Z0-9_]+\(\){ #/ {
|
||||||
info=$0
|
info=$0
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ init_runtime(){
|
|||||||
prompt "generate + commit 'app' startfile?" "$(generate | soften)" "[y/n] "
|
prompt "generate + commit 'app' startfile?" "$(generate | soften)" "[y/n] "
|
||||||
test $answer = "y" || error aborting
|
test $answer = "y" || error aborting
|
||||||
generate > app
|
generate > app
|
||||||
|
echo "export PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')" >> .env
|
||||||
chmod 755 app
|
chmod 755 app
|
||||||
git add app && git commit -m "podi: adding app file"
|
git add app hello.txt .env .pod podi && git commit -m "adding podi"
|
||||||
}
|
}
|
||||||
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
||||||
test -f .pod/start/envfile || recipe start/envfile
|
test -f .pod/start/envfile || recipe start/envfile
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ init_runtime(){
|
|||||||
prompt "generate + commit 'app' startfile?" "$(generate | soften)" "[y/n] "
|
prompt "generate + commit 'app' startfile?" "$(generate | soften)" "[y/n] "
|
||||||
test $answer = "y" || error aborting
|
test $answer = "y" || error aborting
|
||||||
generate > app
|
generate > app
|
||||||
|
echo "export PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')" >> .env
|
||||||
chmod 755 app
|
chmod 755 app
|
||||||
git add app && git commit -m "podi: adding app file"
|
git add app .env .pod podi && git commit -m "adding podi"
|
||||||
}
|
}
|
||||||
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
||||||
test -f .pod/start/envfile || recipe start/envfile
|
test -f .pod/start/envfile || recipe start/envfile
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ init_runtime(){
|
|||||||
generate > app
|
generate > app
|
||||||
chmod 755 app
|
chmod 755 app
|
||||||
echo "HTTP/1.1 200\n\n H E L L O " > hello.txt
|
echo "HTTP/1.1 200\n\n H E L L O " > hello.txt
|
||||||
git add app hello.txt && git commit -m "podi: adding app file"
|
echo "export PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')" >> .env
|
||||||
|
git add app hello.txt .env .pod podi && git commit -m "adding podi"
|
||||||
}
|
}
|
||||||
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
||||||
test -f .pod/start/envfile || recipe start/envfile
|
test -f .pod/start/envfile || recipe start/envfile
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ init_runtime(){
|
|||||||
echo '#!/bin/sh'
|
echo '#!/bin/sh'
|
||||||
echo 'set -x'
|
echo 'set -x'
|
||||||
echo 'POD=$(which podman || which docker)'
|
echo 'POD=$(which podman || which docker)'
|
||||||
echo 'test -z $PODI_APP && export PODI_APP=$(basename $(dir))'
|
echo 'test -z $PODI_APP && export PODI_APP=$(basename $(pwd))'
|
||||||
echo
|
echo
|
||||||
echo '$POD run -d --rm --volume $(pwd):/app -w /app -e PORT -p $PORT:8080 --name $PODI_APP $PODI_APP /redbean.com'
|
echo '$POD run -d --rm --volume $(pwd):/app -w /app -e PORT -p $PORT:8080 --name $PODI_APP $PODI_APP /redbean.com'
|
||||||
echo '$POD logs $PODI_APP'
|
echo '$POD logs $PODI_APP'
|
||||||
@@ -55,9 +55,10 @@ init_runtime(){
|
|||||||
prompt "generate + commit 'app' startfile?" "$(generate | soften)" "[y/n] "
|
prompt "generate + commit 'app' startfile?" "$(generate | soften)" "[y/n] "
|
||||||
test $answer = "y" || error aborting
|
test $answer = "y" || error aborting
|
||||||
echo "FROM docker.io/coderofsalvation/redbean:1.5" > Dockerfile
|
echo "FROM docker.io/coderofsalvation/redbean:1.5" > Dockerfile
|
||||||
|
echo "export PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')" >> .env
|
||||||
generate > app
|
generate > app
|
||||||
chmod 755 app
|
chmod 755 app
|
||||||
git add app Dockerfile && git commit -m "podi: adding app file"
|
git add app Dockerfile .env .pod podi && git commit -m "adding podi"
|
||||||
}
|
}
|
||||||
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
||||||
test -f .pod/start/envfile || recipe start/envfile
|
test -f .pod/start/envfile || recipe start/envfile
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ init_runtime(){
|
|||||||
echo '#!/bin/sh'
|
echo '#!/bin/sh'
|
||||||
echo 'set -x'
|
echo 'set -x'
|
||||||
echo 'POD=$(which podman || which docker)'
|
echo 'POD=$(which podman || which docker)'
|
||||||
echo 'test -z $PODI_APP && export PODI_APP=$(basename $(dir))'
|
echo 'test -z $PODI_APP && export PODI_APP=$(basename $(pwd))'
|
||||||
echo
|
echo
|
||||||
echo '$POD run -d --rm --volume $(pwd):/app -w /app -e PORT -p $PORT:8080 --name $PODI_APP $PODI_APP /redbean.com'
|
echo '$POD run -d --rm --volume $(pwd):/app -w /app -e PORT -p $PORT:8080 --name $PODI_APP $PODI_APP /redbean.com'
|
||||||
echo '$POD logs $PODI_APP'
|
echo '$POD logs $PODI_APP'
|
||||||
@@ -82,7 +82,8 @@ init_runtime(){
|
|||||||
echo "FROM docker.io/coderofsalvation/redbean:1.5" > Dockerfile
|
echo "FROM docker.io/coderofsalvation/redbean:1.5" > Dockerfile
|
||||||
generate > app
|
generate > app
|
||||||
chmod 755 app
|
chmod 755 app
|
||||||
git add app Dockerfile && git commit -m "podi: adding app file"
|
echo "export PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')" >> .env
|
||||||
|
git add app Dockerfile .env .pod podi && git commit -m "adding podi"
|
||||||
}
|
}
|
||||||
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
||||||
test -f .pod/start/envfile || recipe start/envfile
|
test -f .pod/start/envfile || recipe start/envfile
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ init_runtime(){
|
|||||||
chmod 755 app
|
chmod 755 app
|
||||||
echo "HTTP/1.1 200\n\n H E L L O " > hello.txt
|
echo "HTTP/1.1 200\n\n H E L L O " > hello.txt
|
||||||
echo "FROM docker.io/alpine/socat" > Dockerfile
|
echo "FROM docker.io/alpine/socat" > Dockerfile
|
||||||
git add app Dockerfile hello.txt && git commit -m "podi: adding app file"
|
echo "export PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')" >> .env
|
||||||
|
git add app Dockerfile .env hello.txt .pod podi && git commit -m "adding podi"
|
||||||
}
|
}
|
||||||
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
||||||
test -f .pod/start/envfile || recipe start/envfile
|
test -f .pod/start/envfile || recipe start/envfile
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ envset(){ # envset [git@server] [app] [FOO=bar] : shows or sets [remote] environ
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_file_env(){
|
on start envfile
|
||||||
echo "export PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')" >> .env
|
|
||||||
git add .env && git commit -m "podi: adding .env file"
|
|
||||||
}
|
|
||||||
|
|
||||||
on checkout envfile
|
on checkout envfile
|
||||||
on init_localhost ensure_file_env
|
on init_runtime ensure_file_env
|
||||||
|
|||||||
Reference in New Issue
Block a user