diff --git a/README.md b/README.md index c8e3732..82f2441 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ This will create a REST service on root path `/notes`. Also this will add four r ## Install -Supported OS are: Linux, Windows and Mac OS X. If you need support for another OS, please [create new issue](https://github.com/loentar/ngrest/issues/new). +Supported OS are: Linux, Windows and Mac OS X. If you need support for another OS, please [create new issue](https://github.com/loentar/ngrest/issues/new). Furthermore, a [docker file for creating an image](https://github.com/agentS/ngrest/tree/master/docker) is provided. Under Linux installation process is simple. To install ngrest, just open terminal and copy-paste: @@ -148,6 +148,8 @@ wget -qO- http://bit.ly/ngrest | bash [Installation guide with screenshots for Mac OS X](https://github.com/loentar/ngrest/wiki/Installation-guide-with-screenshots-OSX) +[Docker environment](https://github.com/agentS/ngrest/tree/master/docker) + **Notes:** 1. If you don't have one of dependencies required, installer will ask you to enter your password to install it automatically. If you don't want this, press Ctrl+C and start this command: "sudo apt-get install git cmake g++". After apt-get finished, start the line above again. diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100755 index 0000000..0840526 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,26 @@ +FROM ubuntu:18.04 + +RUN apt-get update +RUN apt-get -y install build-essential +RUN apt-get -y install apache2 libapr1-dev apache2-dev +RUN apt-get -y install wget sudo +RUN wget -qO- http://bit.ly/ngrest | bash +RUN touch ~/.ngrest/ngrest/CMakeLists.txt; make -C ~/.ngrest/ngrest-build + +RUN cp ~/.ngrest/ngrest/modules/apache2/conf/ngrest.* /etc/apache2/mods-available/ +COPY ngrest.load /etc/apache2/mods-available/ngrest.load +COPY ngrest.conf /etc/apache2/mods-available/ngrest.conf +RUN a2enmod ngrest +COPY ports.conf /etc/apache2/ports.conf + +RUN mkdir /usr/src/projects +WORKDIR /usr/src/projects +RUN apt-get -y install inotify-tools + +RUN chmod go+rx /root +EXPOSE 80 +EXPOSE 9098 + +RUN a2enmod headers + +ENTRYPOINT [ "/bin/bash" ] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..aed9913 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,32 @@ +# Dockerfile for ngrest + +This directory provides a docker file for building a container capable of compiling and running ngrest applications. + +## Building and developing + +The file [dockerBuild.sh](dockerBuild.sh) provides the command for building the docker container, while [dockerRun.sh](dockerRun.sh) provides instructions for starting the container. + +The directory `/usr/src/projects` should be used as base for your ngrest application. +Special attention has to be given to given to the `-v` option. +This option specifies the source ngrest directory mounted into the docker container. +Just replace `/media/lukas/LUKAS_ESSD_EXT4/programming/cpp/unmangler` with the path to your source code directory on your host machine. + +Once you start your container, a shell should open and you should be inside the directory `/usr/src/projects`. +From there you can execute the usual `ngrest` commands. + +Your application should be reachable via `http://localhost:9098//`. + +## Production environment + +This container can be used as base for your application's production container. An example docker file [can be found here.](https://github.com/agentS/UnmanglerBackend/blob/master/Dockerfile) + +The line `FROM ngrest` makes the production container inherit from the base container. + +The following lines copy the source code into the production container as well as build and deploy the application. + COPY . /usr/src/projects + RUN ngrest clean + RUN ngrest build + RUN cp .ngrest/local/build/services/unmangler.so /root/.ngrest/ngrest-build/deploy/share/ngrest/services + +The line `ENTRYPOINT [ "/usr/sbin/apache2ctl", "-D", "FOREGROUND" ]` starts the Apache 2 web server in the foreground of the container. +This prevents docker from immediately stopping the container once the web server was started. diff --git a/docker/dockerBuild.sh b/docker/dockerBuild.sh new file mode 100755 index 0000000..8f87bac --- /dev/null +++ b/docker/dockerBuild.sh @@ -0,0 +1,3 @@ +#! env /bin/bash + +sudo docker build -t ngrest . diff --git a/docker/dockerRun.sh b/docker/dockerRun.sh new file mode 100755 index 0000000..31be928 --- /dev/null +++ b/docker/dockerRun.sh @@ -0,0 +1,3 @@ +#! env /bin/bash + +sudo docker run --rm -it -p 80:80 -p 9098:9098 -v /media/lukas/LUKAS_ESSD_EXT4/programming/cpp/unmangler:/usr/src/projects --name=ngrest ngrest diff --git a/docker/ngrest.conf b/docker/ngrest.conf new file mode 100755 index 0000000..c6cd343 --- /dev/null +++ b/docker/ngrest.conf @@ -0,0 +1,15 @@ + + # path to deploy ngrest services from + ServicesPath /root/.ngrest/ngrest-build/deploy/share/ngrest/services + # filters path is optional. comment this line if you do not use filters + FiltersPath /root/.ngrest/ngrest-build/deploy/share/ngrest/filters + + # location regex on which ngrest is bound. + # this will bind /ngrest and /echo locations + + SetHandler ngrest + + + SetHandler ngrest + + diff --git a/docker/ngrest.load b/docker/ngrest.load new file mode 100755 index 0000000..3aaa561 --- /dev/null +++ b/docker/ngrest.load @@ -0,0 +1,2 @@ +LoadModule ngrest_module /root/.ngrest/ngrest-build/deploy/share/ngrest/modules/apache2/mod_ngrest.so + diff --git a/docker/ports.conf b/docker/ports.conf new file mode 100755 index 0000000..a571148 --- /dev/null +++ b/docker/ports.conf @@ -0,0 +1,16 @@ +# If you just change the port or add more ports here, you will likely also +# have to change the VirtualHost statement in +# /etc/apache2/sites-enabled/000-default.conf + +Listen *:80 + + + Listen *:443 + + + + Listen *:443 + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +