/nunit-Ceasy

Complies C code natively and links it to NGINX Unit's `libunit.a` so you can register your native C app.

Primary LanguageDockerfileApache License 2.0Apache-2.0

nunit-Ceasy

Complies C code natively and links it to NGINX Unit's libunit.a so you can register your native C app.

Inspired by the article NGINX Unit Adds Assembly Language Support.

Docker

  1. Add required Unit header files to your C code. i.e.
#include "nxt_clang.h"
#include "nxt_unit.h"
#include "nxt_unit_request.h"
#include "nxt_unit_typedefs.h"

Unit source files will be included in the docker image, so you don't need local copies.

  1. Put your app source files in the src/ directory.
  2. Rename your maic C file to main.c; or change the expected file name in the Dockerfile.
  3. Build the docker image:
docker build -t nunit:latest .
  1. Run the docker container:
docker run --rm -p 8081:8081 nunit:latest
  1. See your app running at localhost:8081!

Local

Requirements

Compiling libunit.a requires the Unit source code, see https://unit.nginx.org/installation/

  1. Run
UNIT_SRC=/path/to/unit make prepare

to create libunit.a and copy over the necessary header to include/

  1. Run make

  2. Run your app ./app

Sample

  1. Run
UNIT_SRC=/path/to/unit make sample
  1. Run ./sample or build the docker image:
docker build -t nunit:sample -f Dockerfile.sample .