+ docker-compose and other goodies

pack
Dominika 2021-11-10 23:50:33 +01:00
parent 52c09d888e
commit 0793241a3b
5 changed files with 36 additions and 12 deletions

View File

@ -1,3 +1,4 @@
secret/*
app
config
storage

View File

@ -3,11 +3,13 @@ FROM alpine:3.14
RUN apk update \
&& apk add sed xxd grep findutils file nmap-ncat socat jq bash file curl
WORKDIR /app
WORKDIR /httpsh
COPY . .
EXPOSE 1337
VOLUME /app/config
VOLUME /app/app
VOLUME /httpsh/config
VOLUME /httpsh/app
VOLUME /httpsh/storage
VOLUME /httpsh/secret
ENTRYPOINT /app/http.sh
CMD ["/httpsh/http.sh"]

View File

@ -1,5 +1,5 @@
# HTTP.sh
Node.js, but `| sed s/Node/HTTP/;s/js/sh/`.
Node.js, but `| sed 's/Node/HTTP/;s/js/sh/'`.
HTTP.sh is (by far) the most extensible attempt at creating a web framework in Bash, and (AFAIK) the only one that's actively maintained. Although I strive for code quality, this is still rather experimental and may contain bugs.
@ -21,6 +21,8 @@ git clone https://git.sakamoto.pl/laudom/ocw/ app # example repo :P
./http.sh
```
We also support Docker! Both a Dockerfile and an example docker-compose.yml are included for your convenience. Containerizing your webapp is as easy as `docker-compose up -d`
## Dependencies
- Bash (4.x should work, but we'll need 5.0 soon)

19
docker-compose.yml Normal file
View File

@ -0,0 +1,19 @@
# example docker-compose for HTTP.sh
# adapt to your liking. serves 4 people
version: '3'
services:
httpsh:
build:
context: .
dockerfile: Dockerfile
image: httpsh
restart: always
ports:
- '1337:1337'
volumes:
- './config:/httpsh/config'
- './app:/httpsh/app'
- './secret:/httpsh/secret'
- './storage:/httpsh/storage'

14
http.sh
View File

@ -3,10 +3,10 @@ trap ctrl_c INT
if [[ ! -f "config/master.sh" ]]; then
mkdir -p config
cat <<PtrcIsCute > "config/master.sh"
cat <<MaeIsCute > "config/master.sh"
declare -A cfg
cfg[ip]=127.0.0.1 # IP address to bind to - use 0.0.0.0 to bind to all
cfg[ip]=0.0.0.0 # IP address to bind to - use 0.0.0.0 to bind to all
cfg[http]=true # enables/disables listening on HTTP
cfg[port]=1337 # HTTP port
@ -46,7 +46,7 @@ cfg[mail_server]=""
cfg[mail_password]=""
cfg[mail_ssl]=true
cfg[mail_ignore_bad_cert]=false
PtrcIsCute
MaeIsCute
fi
source config/master.sh
@ -122,7 +122,7 @@ echo "<h1>Hello from HTTP.sh!</h1><br>To get started with your app, check out $(
<li>$(pwd)/src/ - HTTP.sh src, feel free to poke around ;P</li></ul>
&copy; sdomi, ptrcnull, selfisekai - 2020, 2021"
LauraIsCute
cat <<PtrcIsCute > "${cfg[namespace]}/routes.sh"
cat <<MaeIsCute > "${cfg[namespace]}/routes.sh"
## routes - application-specific routes
##
## HTTP.sh supports both serving files using a directory structure (webroot),
@ -137,7 +137,7 @@ LauraIsCute
# router "/test" "app/views/test.shs"
# router "/profile/:user" "app/views/user.shs"
PtrcIsCute
MaeIsCute
chmod +x "${cfg[namespace]}/workers/example/worker.sh"
@ -145,14 +145,14 @@ PtrcIsCute
exit 0
fi
cat <<PtrcIsCute >&2
cat <<MaeIsCute >&2
_ _ _______ _______ _____ ______ _ _
| | | |_______|_______| _ \/ ___/| | | |
| |__| | | | | | | |_| | |___ | |__| |
| |__| | | | | | | ___/\___ \ | |__| |
| | | | | | | | | | ___\ \| | | |
|_| |_| |_| |_| |_| □ /_____/|_| |_|
PtrcIsCute
MaeIsCute
if [[ "$1" == "debug" ]]; then
cfg[dbg]=true