diff --git a/.dockerignore b/.dockerignore index 03db58a..e62c393 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ secret/* app config +storage diff --git a/Dockerfile b/Dockerfile index f683bb1..5badeb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index 8f76c3a..939c020 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0e3e872 --- /dev/null +++ b/docker-compose.yml @@ -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' diff --git a/http.sh b/http.sh index ff85331..7688bcd 100755 --- a/http.sh +++ b/http.sh @@ -3,10 +3,10 @@ trap ctrl_c INT if [[ ! -f "config/master.sh" ]]; then mkdir -p config - cat < "config/master.sh" + cat < "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 "

Hello from HTTP.sh!


To get started with your app, check out $(
  • $(pwd)/src/ - HTTP.sh src, feel free to poke around ;P
  • © sdomi, ptrcnull, selfisekai - 2020, 2021" LauraIsCute - cat < "${cfg[namespace]}/routes.sh" + cat < "${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 <&2 +cat <&2 _ _ _______ _______ _____ ______ _ _ | | | |_______|_______| _ \/ ___/| | | | | |__| | | | | | | |_| | |___ | |__| | | |__| | | | | | | ___/\___ \ | |__| | | | | | | | | | | | ___\ \| | | | |_| |_| |_| |_| |_| □ /_____/|_| |_| -PtrcIsCute +MaeIsCute if [[ "$1" == "debug" ]]; then cfg[dbg]=true