Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
Expand Down
26 changes: 26 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
32 changes: 32 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -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/<insert your application name>/<insert your endpoint>`.

## 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.
3 changes: 3 additions & 0 deletions docker/dockerBuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! env /bin/bash

sudo docker build -t ngrest .
3 changes: 3 additions & 0 deletions docker/dockerRun.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions docker/ngrest.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<IfModule mod_ngrest.c>
# 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
<Location ~ "/(ngrest|echo)">
SetHandler ngrest
</Location>
<Location ~ "/unmangler">
SetHandler ngrest
</Location>
</IfModule>
2 changes: 2 additions & 0 deletions docker/ngrest.load
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LoadModule ngrest_module /root/.ngrest/ngrest-build/deploy/share/ngrest/modules/apache2/mod_ngrest.so

16 changes: 16 additions & 0 deletions docker/ports.conf
Original file line number Diff line number Diff line change
@@ -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

<IfModule ssl_module>
Listen *:443
</IfModule>

<IfModule mod_gnutls.c>
Listen *:443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet