diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..20c0166 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,28 @@ +name: Docker Hub + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set login + uses: azure/docker-login@v1 + with: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Build image + working-directory: ${{github.workspace}} + run: ./build.sh + + - name: Push image + run: docker push natechoe/swebs diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..839869e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM debian:stable-slim AS build +RUN apt-get update -y && apt-get upgrade -y && apt-get install -y libgnutls28-dev libgnutls30 gcc make pkg-config +COPY . /swebs +WORKDIR /swebs +RUN make + +FROM debian:stable-slim AS run +RUN apt-get update -y && apt-get upgrade -y && apt-get install -y libgnutls28-dev libgnutls30 +COPY --from=build /swebs/build/swebs /usr/sbin/swebs +COPY ./site /site + +ENTRYPOINT [ "swebs", "-s", "/site/sitefile" ] diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..3f86787 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +docker build . -t natechoe/swebs diff --git a/site/sitefile b/site/sitefile new file mode 100644 index 0000000..7f67ef1 --- /dev/null +++ b/site/sitefile @@ -0,0 +1,4 @@ +define transport TCP +define port 8000 + +read .* /site/ diff --git a/src/responses.c b/src/responses.c index 3659636..0b0653c 100644 --- a/src/responses.c +++ b/src/responses.c @@ -16,6 +16,8 @@ along with this program. If not, see . */ +#include + #include #include @@ -29,6 +31,9 @@ #include #include +char *realpath(char *, char *); +/* I don't know why, but realpath breaks on debian. */ + static int readResponse(Connection *conn, char *path) { int fd = -1; struct stat statbuf;