More on clixon base container on Alpine

This commit is contained in:
Olof Hagsand 2019-02-12 11:11:04 +01:00
parent 973e5d7507
commit f02310dcef
7 changed files with 62 additions and 13 deletions

View file

@ -197,7 +197,7 @@ forbidden(FCGX_Request *r)
path = FCGX_GetParam("DOCUMENT_URI", r->envp);
FCGX_FPrintF(r->out, "Status: 403\r\n"); /* 403 forbidden */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Grideye Forbidden</h1>\n");
FCGX_FPrintF(r->out, "<h1>Forbidden</h1>\n");
FCGX_FPrintF(r->out, "The requested URL %s was forbidden.\n", path);
return 0;
}
@ -267,7 +267,7 @@ internal_server_error(FCGX_Request *r)
path = FCGX_GetParam("DOCUMENT_URI", r->envp);
FCGX_FPrintF(r->out, "Status: 500\r\n"); /* 500 internal server error */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Grideye Internal server error when accessing %s</h1>\n", path);
FCGX_FPrintF(r->out, "<h1>Internal server error when accessing %s</h1>\n", path);
return 0;
}

View file

@ -504,7 +504,7 @@ usage(clicon_handle h,
exit(0);
}
/*! Main routine for grideye fastcgi API
/*! Main routine for fastcgi API
*/
int
main(int argc,

View file

@ -59,12 +59,17 @@ Define a valid CLICON_SOCK_GROUP in the config file or via the -g option
or create the group and add the user to it. The default group is 'clicon'.
Add yourself and www-data, if you intend to use restconf.
On linux:
Using groupadd and usermod:
```
sudo groupadd clicon
sudo groupadd clicon #
sudo usermod -a -G clicon <user>
sudo usermod -a -G clicon www-data
```
Using addgroup and adduser (eg on busybox):
```
sudo addgroup clicon
sudo adduser <user> clicon
```
(you may have to restart shell)
Verify:

View file

@ -37,11 +37,11 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
# For clixon and cligen
RUN apk add --update git make build-base gcc flex bison fcgi-dev curl-dev
# For debug
RUN apk add --update bash nano
# Create a directory to hold source-code, dependencies etc
RUN mkdir /clixon
RUN mkdir /clixon/build
WORKDIR /clixon
# Clone cligen
@ -49,7 +49,7 @@ RUN git clone https://github.com/olofhagsand/cligen.git
# Build cligen
WORKDIR /clixon/cligen
RUN ./configure
RUN ./configure --prefix=/clixon/build
RUN make
RUN make install
@ -59,11 +59,33 @@ WORKDIR /clixon/clixon
COPY clixon .
# Build clixon (without restconf if you dont have nginx)
RUN ./configure --without-restconf
RUN ./configure --without-restconf --prefix=/clixon/build --with-cligen=/clixon/build
RUN make
RUN make install
RUN make install-include
WORKDIR /clixon/clixon/example
RUN DESTDIR=/clixon/build make
RUN make install
#
# Stage 2
#
FROM alpine
MAINTAINER Olof Hagsand <olof@hagsand.se>
# For clixon and cligen
RUN apk add --update flex bison # fcgi-dev curl-dev
# Run a clicon group - actually an application may want another
RUN addgroup clicon
COPY --from=0 /clixon/build/ /usr/local/
# For debug
#RUN apk add --update bash nano

View file

@ -20,3 +20,28 @@ the docker runtime scripts there
(You may have to login for push with sudo docker login -u <username>)
## Example run
The following shows a simple example of how to run the example
application. First,the container is started, then the backend is startend in the background inside the container, and finally the CLI is started in the foreground.
```
$ sudo docker run --name clixon --rm -td clixon/clixon
$ sudo docker exec -it clixon clixon_backend -s init -f /usr/local/etc/example.xml
$ sudo docker exec -it clixon clixon_cli -f /usr/local/etc/example.xml
> set interfaces interface e
> show configuration
interfaces {
interface {
name e;
enabled true;
}
}
> q
$ sudo docker kill clixon
```
Note that this is a special case since the example is
already a part of the installation. If you want to add your own
application, such as plugins, cli syntax files, yang models, etc, you
need to extend the base container with your own additions.

View file

@ -1,13 +1,10 @@
#!/bin/bash
# Build grideye containers, start all containers, setup networking
# Usage: ./startup.sh
# Debug: DBG=1 ./startup.sh
# See also cleanup.sh
>&2 echo "Running script: $0"
pwd
# Error function
# usage: err $msg
err(){
@ -53,7 +50,6 @@ EOF
CONFIG=${CONFIG:-$CONFIG0}
# Start clixon-example backend
# -p 4535 to access via cli from host
>&2 echo -n "Starting Backend..."
sudo docker run -p $PORT:80 --name clixon-system --rm -e DBG=$DBG -e CONFIG="$CONFIG" -e STORE="$STORE" -td clixon/clixon-system || err "Error starting clixon-system"

View file

@ -57,6 +57,7 @@
#include <ctype.h>
#include <unistd.h>
#define __USE_GNU /* strverscmp */
#define _GNU_SOURCE
#include <string.h>
#include <arpa/inet.h>
#include <regex.h>