diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3fc24ebf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM hayd/alpine-deno:1.6.2 +EXPOSE 8000 +WORKDIR /app +USER deno +COPY deps.ts . +RUN deno cache deps.ts +ADD . . +RUN deno cache server.ts # --unstable? +CMD ["./run.sh"] diff --git a/README.md b/README.md new file mode 100644 index 00000000..2b25bd6f --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# Pikne Zadania + + +## Installation + +[Install Docker](https://docs.docker.com/engine/install/) if it's not installed. If you are on Unix-based distro, you can try: + +```sh +# use the docker/docker-install script when you are lazy +curl -fsSL https://get.docker.com | sh +``` + +and don't forget to start `docker` service (with `service` or `systemctl`): + +```sh +# start the docker service if it's not started +sudo service docker start +# enable it if you want to run docker at the boot +sudo service docker enable +``` + +Run our container (use `sudo` if you are not in `docker` group): + +```sh +PORT=80 +docker run --name pikne-zadania -dp $PORT:8000 nircek/pikne-zadania +# or if you want to run it at the boot +docker run --name pikne-zadania -dp $PORT:8000 --restart unless-stopped nircek/pikne-zadania +``` + +Perform updates automatically with the [Watchtower](https://github.com/containrrr/watchtower): + +```sh +docker run --name watchtower -dv /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower +``` diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..9c904577 --- /dev/null +++ b/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh +trap interrupt TERM INT +interrupt () { + echo "Interrupting with SIGINT and waiting 5s... " + kill $pid + timeout 5 sh -c "while kill -0 $pid &>/dev/null; do :; done" + exit +} + +( + deno run --allow-net --allow-read=/app server.ts & + trap "kill -SIGINT $!; wait $!" TERM + wait $! +) & +pid=$! +wait