diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2a4b189 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +# Production container: only core debian and treebird FCGI deps +FROM debian:testing + +RUN apt update && apt upgrade -y +RUN apt install -y libcurl3-gnutls libfcgi0ldbl fcgiwrap + +WORKDIR treebird +COPY treebird-fcgi /usr/local/bin/treebird + +CMD fcgiwrap -c 10 -f -s tcp:0.0.0.0:4008 diff --git a/build_container.sh b/build_container.sh index a180b6b..5c73def 100755 --- a/build_container.sh +++ b/build_container.sh @@ -1,7 +1,32 @@ #!/bin/sh -# builds the 'build' image for compiling and testing +# Builds both the 'build' and release containers. The build container is used to +# compile the code and is kept independently so it can actually be run for testing +# and debugging, but only the release image should be run on production servers. +release=${1:-latest} +outdir="treebird-${release}" git submodule init git submodule update -docker build -t treebird:build -f Dockerfile.build . +build_image="treebird:${release}-build" +docker build -t "${build_image}" -f Dockerfile.build . + +[ $? -eq 0 ] || (exit 1 && echo build failed!) + +[ -d "${outdir}" ] || mkdir "${outdir}" + +static_files="/usr/local/share/treebird/dist/." +fcgi_bin_pth="/usr/local/bin/treebird" + +docker run --rm --name "${outdir}-tmp" -d "${build_image}" +docker cp "${outdir}-tmp:${static_files}" "${outdir}/" +docker cp "${outdir}-tmp:${fcgi_bin_pth}" "${outdir}/" +docker stop "${outdir}-tmp" + +[ $? -eq 0 ] || (exit 1 && echo failed to extract to outdir) + +cp "${outdir}/treebird" treebird-fcgi +docker build -t "treebird:${release}" . +rm treebird-fcgi + +[ $? -eq 0 ] || (exit 1 && echo failed to build release image) diff --git a/nginx-test/build_container.sh b/nginx-test/build_container.sh index ec918bd..9f28914 100755 --- a/nginx-test/build_container.sh +++ b/nginx-test/build_container.sh @@ -1,2 +1,10 @@ #!/bin/sh +# builds a quick improvised nginx container to run treebird locally +release=${1:-latest} + +[ ! -d to-webserv ] || rm -vr to-webserv + +mkdir to-webserv +cp -r "../treebird-${release}/." to-webserv + docker build -t treebird-nginx-test . diff --git a/run_container.sh b/run_container.sh index 347a144..702efd6 100755 --- a/run_container.sh +++ b/run_container.sh @@ -1,4 +1,11 @@ #!/bin/sh # runs the treebird image as a docker daemon +instance=${1:-https://sleepy.cafe/} +release=${2:-latest} -docker run --rm --name treebird -p 4008:4008 -e TREEBIRD_CFG_INSTANCE_URL="https://sleepy.cafe/" -d treebird:build +docker run \ + --rm \ + --name treebird \ + -p 4008:4008 \ + -e TREEBIRD_CFG_INSTANCE_URL="${instance}" \ + -d "treebird:${release}"