diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b7b6c0e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM gcc + +RUN \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get -y install \ + cmake \ + libboost-program-options-dev \ + libboost-thread-dev \ + libevent-dev \ + libgtest-dev \ + libsqlite3-dev \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/ + +RUN \ + mkdir -vp /tmp/.build && cd /tmp/.build && \ + cmake -DCMAKE_BUILD_TYPE=RELEASE /usr/src/gtest/ && \ + make && \ + mv -v libgtest* /usr/lib/ && \ + rm -vrf /tmp/.build && cd - + +COPY . /usr/src/udpt +WORKDIR /usr/src/udpt + +RUN \ + cmake -DCMAKE_BUILD_TYPE=Release . && \ + make udpt -j8 + +ENTRYPOINT [ "./udpt", "--interactive" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..626a5bb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +udpt: + build: . + ports: + - 6969:6969/udp + - 127.0.0.1:8081:8081 + volumes: + - ./udpt.conf:/etc/udpt.conf:ro diff --git a/docs/building.rst b/docs/building.rst index adea47c..c33b62c 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -68,6 +68,35 @@ This should leave you with a udpt executable file, and optionally a udpt_tests e If everything succeeded, head over to :doc:`udpt.conf` and get your tracker running! +Building with Docker +==================== +Complete working Docker workflow is possible allowing you to start hacking and building without any other requirements or dependencies. All the required libs and build tools are handled by Docker build process. + +Using the provided Dockerfile you can build a complete working image with all the required dependencies. + +If you're not familiar with Docker, better use Docker Compose to both build and run your source easy and effortlessly. + +From the ``docker-compose.yml`` directory, run:: + + docker-compose up --build + +Skip the ``--build`` switch to launch the last built container image without rebuilding again. + +The provided ``docker-compose.yml`` file is configured to: + +* Expose daemon's ports to host (using port's defaults). API server is only exposed on 127.0.0.1 to the Docker host. +* Mount your host's ``udpt.conf`` from your source tree inside the container at ``/etc/udpt.conf`` (read-only). +* Start with the ``--interactive`` switch to avoid forking to background, as required with Docker. + +To run udpt inside a Docker container, you need to: + +* Configure logging to ``/dev/stdout`` to send the program's messages to Docker's standard logging. +* Configure API server to listen to 0.0.0.0 inside the container to be able to contact it from your development host, that is from outside the container. + +See the ``docker-compose.yml`` to view and tweak the launch parameters. + +Stop the container by ``CTRL+C``'ing it. + Building for Windows ==================== .. note:: This documentation is a work-in-progress. Stay tuned! diff --git a/src/WebApp.hpp b/src/WebApp.hpp index 91d5aa2..32c94fe 100644 --- a/src/WebApp.hpp +++ b/src/WebApp.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "db/database.hpp" @@ -79,4 +80,4 @@ namespace UDPT static void sendReply(struct ::evhttp_request *req, int code, const char *reason, const std::string &response); static void sendReply(struct ::evhttp_request *req, int code, const char *reason, const char *response, size_t len); }; -} \ No newline at end of file +}