* Changed base OS in clixon-system container to Alpine
* Moved datastore/text/ code to datastore/ since there is only one type of datastore. * Added "magic script line" to test script for sourced and scriped exits
This commit is contained in:
parent
9fc8ac2e8e
commit
d64d433468
58 changed files with 579 additions and 538 deletions
|
|
@ -37,11 +37,9 @@ 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
|
||||
|
||||
|
||||
# Create a directory to hold source-code, dependencies etc
|
||||
RUN mkdir /clixon
|
||||
RUN mkdir /clixon/build
|
||||
|
||||
WORKDIR /clixon
|
||||
|
||||
# Clone cligen
|
||||
|
|
@ -58,37 +56,54 @@ RUN mkdir /clixon/clixon
|
|||
WORKDIR /clixon/clixon
|
||||
COPY clixon .
|
||||
|
||||
# Build clixon (without restconf if you dont have nginx)
|
||||
RUN ./configure --without-restconf --prefix=/clixon/build --with-cligen=/clixon/build
|
||||
# Need to add www user manually
|
||||
RUN adduser -D -H www-data
|
||||
# nginx adds group www-data
|
||||
RUN apk add --update nginx
|
||||
|
||||
# Configure, build and install clixon
|
||||
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-wwwuser=www-data
|
||||
RUN make
|
||||
RUN make install
|
||||
RUN make install-include
|
||||
|
||||
# Build and install the clixon example (not really necessary for base)
|
||||
WORKDIR /clixon/clixon/example
|
||||
RUN DESTDIR=/clixon/build make
|
||||
RUN make
|
||||
RUN make install
|
||||
RUN install example.xml /clixon/build/etc/clixon.xml
|
||||
|
||||
#
|
||||
# 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 apk add --update flex bison fcgi-dev
|
||||
|
||||
# Run a clicon group - actually an application may want another
|
||||
# need to add www user manually
|
||||
RUN adduser -D -H www-data
|
||||
# nginx adds group www-data
|
||||
RUN apk add --update nginx
|
||||
|
||||
# Test-specific (for test scripts)
|
||||
#RUN apk add --update sudo curl bash
|
||||
|
||||
# Expose nginx port for restconf
|
||||
EXPOSE 80
|
||||
|
||||
# Create clicon group
|
||||
RUN addgroup clicon
|
||||
RUN adduser nginx clicon
|
||||
RUN adduser www-data clicon
|
||||
|
||||
COPY --from=0 /clixon/build/ /usr/local/
|
||||
COPY --from=0 /www-data /www-data
|
||||
|
||||
# For debug
|
||||
#RUN apk add --update bash nano
|
||||
|
||||
|
||||
|
||||
|
||||
# Manually created
|
||||
RUN chown www-data /www-data
|
||||
RUN chgrp www-data /www-data
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,23 +12,24 @@ See [clixon-system](../system/README.md) for a more complete clixon image.
|
|||
|
||||
## Build and push
|
||||
|
||||
Perform the build by `make docker`.
|
||||
You may also do `make push` if you want to push the image, but you may then consider changing the image name (in the makefile:s).
|
||||
Perform the build by `make docker`. This copies the latest _committed_ clixon code into the container.
|
||||
|
||||
You may run the container directly by going directly to example and
|
||||
the docker runtime scripts there
|
||||
You may also do `make push` if you want to push the image, but you may then consider changing the image name (in the makefile:s).
|
||||
|
||||
(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.
|
||||
The base container is a minimal and primitive example. Look at the [clixon-system](../system) for a more stream-lined application.
|
||||
|
||||
The following shows a simple example of how to run the example
|
||||
application. First, the container is started with the backend running:
|
||||
```
|
||||
$ 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
|
||||
$ sudo docker run --rm --name clixon-base -d clixon/clixon clixon_backend -Fs init
|
||||
```
|
||||
Then a CLI is started, and finally the container is removed:
|
||||
```
|
||||
$ sudo docker exec -it clixon-base clixon_cli
|
||||
> set interfaces interface e
|
||||
> show configuration
|
||||
interfaces {
|
||||
|
|
@ -38,10 +39,10 @@ application. First,the container is started, then the backend is startend in the
|
|||
}
|
||||
}
|
||||
> q
|
||||
$ sudo docker kill clixon
|
||||
$ sudo docker kill clixon-base
|
||||
```
|
||||
|
||||
Note that this is a special case since the example is
|
||||
Note that the clixon example application 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.
|
||||
|
|
|
|||
16
docker/base/start.sh
Executable file
16
docker/base/start.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
# Usage: ./startup.sh
|
||||
# Debug: DBG=1 ./startup.sh
|
||||
# See also cleanup.sh
|
||||
|
||||
>&2 echo "Running script: $0"
|
||||
|
||||
|
||||
# Start clixon-example backend
|
||||
sudo docker run --name clixon --rm -td clixon/clixon || err "Error starting clixon"
|
||||
|
||||
>&2 echo "clixon started"
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -31,34 +31,23 @@
|
|||
# ***** END LICENSE BLOCK *****
|
||||
#
|
||||
|
||||
# This application could use the base image, but it does not at this point.
|
||||
FROM debian
|
||||
FROM alpine
|
||||
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
||||
|
||||
# Clixon dependenies (not needed if build from base)
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git make gcc flex bison \
|
||||
libfcgi-dev \
|
||||
libcurl4-openssl-dev
|
||||
|
||||
# Application-specific
|
||||
RUN apt-get update && apt-get install -y nginx
|
||||
|
||||
# Test-specific (for test scripts)
|
||||
RUN apt-get update && apt-get install -y sudo curl procps time
|
||||
|
||||
# The example uses "clicon" group
|
||||
RUN groupadd clicon
|
||||
RUN usermod -a -G clicon www-data
|
||||
# For clixon and cligen
|
||||
RUN apk add --update git make build-base gcc flex bison fcgi-dev curl-dev
|
||||
|
||||
# Create a directory to hold source-code, dependencies etc
|
||||
RUN mkdir /clixon
|
||||
RUN mkdir /clixon/build
|
||||
WORKDIR /clixon
|
||||
|
||||
# Clone and build cligen (not necessary if use base image)
|
||||
# Clone cligen
|
||||
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
|
||||
|
||||
|
|
@ -67,30 +56,69 @@ RUN mkdir /clixon/clixon
|
|||
WORKDIR /clixon/clixon
|
||||
COPY clixon .
|
||||
|
||||
RUN ./configure
|
||||
# Need to add www user manually
|
||||
RUN adduser -D -H www-data
|
||||
# nginx adds group www-data
|
||||
RUN apk add --update nginx
|
||||
|
||||
# Configure, build and install clixon
|
||||
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-wwwuser=www-data
|
||||
RUN make
|
||||
RUN make install
|
||||
RUN make install-include
|
||||
|
||||
# Install utils
|
||||
WORKDIR /clixon/clixon/util
|
||||
RUN make
|
||||
RUN make install
|
||||
|
||||
# Build and install the clixon example
|
||||
WORKDIR /clixon/clixon/example
|
||||
RUN make
|
||||
RUN make install
|
||||
RUN install example.xml /usr/local/etc/clixon.xml
|
||||
RUN install example.xml /clixon/build/etc/clixon.xml
|
||||
|
||||
RUN ldconfig
|
||||
# Copy tests
|
||||
WORKDIR /clixon/clixon/test
|
||||
RUN install -d /clixon/build/bin/test
|
||||
RUN install *.sh /clixon/build/bin/test
|
||||
|
||||
# Copy startscript
|
||||
WORKDIR /clixon
|
||||
COPY startsystem.sh startsystem.sh
|
||||
RUN install startsystem.sh /usr/local/bin/
|
||||
RUN install startsystem.sh /clixon/build/bin/
|
||||
|
||||
#
|
||||
# Stage 2
|
||||
#
|
||||
FROM alpine
|
||||
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
||||
|
||||
# For clixon and cligen
|
||||
RUN apk add --update flex bison fcgi-dev
|
||||
|
||||
# need to add www user manually
|
||||
RUN adduser -D -H www-data
|
||||
# nginx adds group www-data
|
||||
RUN apk add --update nginx
|
||||
|
||||
# Test-specific (for test scripts)
|
||||
RUN apk add --update sudo curl procps grep make bash
|
||||
|
||||
# Expose nginx port for restconf
|
||||
EXPOSE 80
|
||||
|
||||
# Create clicon group
|
||||
RUN addgroup clicon
|
||||
RUN adduser nginx clicon
|
||||
RUN adduser www-data clicon
|
||||
|
||||
COPY --from=0 /clixon/build/ /usr/local/
|
||||
COPY --from=0 /www-data /www-data
|
||||
|
||||
# Manually created
|
||||
RUN chown www-data /www-data
|
||||
RUN chgrp www-data /www-data
|
||||
|
||||
# Log to stderr.
|
||||
CMD /usr/local/bin/startsystem.sh
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ push:
|
|||
# Start the clixon system container and run the test script
|
||||
test: docker
|
||||
./cleanup.sh ; PORT=8080 ./start.sh # kill (ignore error) and the start it
|
||||
sudo docker exec -it clixon-system bash -c 'cd /clixon/clixon/test && ./all.sh'
|
||||
sudo docker exec -it clixon-system bash -c 'cd /usr/local/bin/test && ./all.sh'
|
||||
|
||||
depend:
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ As restconf using curl on exposed port 80:
|
|||
```
|
||||
Or run tests:
|
||||
```
|
||||
$ sudo docker exec -it clixon-system bash -c 'cd /clixon/clixon/test&& ./all.sh'
|
||||
$ sudo docker exec -it clixon-system bash -c 'cd /usr/local/bin/test&& ./all.sh'
|
||||
```
|
||||
|
||||
To check status and then kill it:
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
DBG=${DBG:-0}
|
||||
|
||||
WWWUSER=${WWWUSER:-www-data}
|
||||
|
||||
# Initiate clixon configuration (env variable)
|
||||
echo "$CONFIG" > /usr/local/etc/clixon.xml
|
||||
|
||||
|
|
@ -19,7 +21,7 @@ echo "$STORE" > /usr/local/var/example/running_db
|
|||
|
||||
>&2 echo "Write nginx config files"
|
||||
# nginx site config file
|
||||
cat <<EOF > /etc/nginx/sites-enabled/default
|
||||
cat <<EOF > /etc/nginx/conf.d/default.conf
|
||||
#
|
||||
server {
|
||||
listen 80 default_server;
|
||||
|
|
@ -28,7 +30,6 @@ server {
|
|||
server_name localhost;
|
||||
server_name _;
|
||||
location / {
|
||||
root /usr/share/nginx/html/restconf;
|
||||
fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
|
@ -46,13 +47,17 @@ server {
|
|||
EOF
|
||||
|
||||
# This is a clixon site test file. Disable all model testing.
|
||||
cat <<EOF > /clixon/clixon/test/site.sh
|
||||
cat <<EOF > /usr/local/bin/test/site.sh
|
||||
# Add your local site specific env variables (or tests) here.
|
||||
MODELS=0 # Dont run yangmodels/openconfig tests
|
||||
IETFRFC=/clixon/clixon/yang/standard
|
||||
SKIPLIST="test_yangmodels.sh test_openconfig.sh test_install.sh test_order.sh"
|
||||
#IETFRFC=
|
||||
EOF
|
||||
|
||||
chmod 775 /usr/local/bin/test/site.sh
|
||||
|
||||
if [ ! -d /run/nginx ]; then
|
||||
mkdir /run/nginx
|
||||
fi
|
||||
|
||||
# Start nginx
|
||||
#/usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/nginx.conf
|
||||
|
|
@ -60,9 +65,12 @@ EOF
|
|||
>&2 echo "nginx started"
|
||||
|
||||
# Start clixon_restconf
|
||||
su -c "/www-data/clixon_restconf -l f/www-data/restconf.log -D $DBG" -s /bin/sh www-data &
|
||||
su -c "/www-data/clixon_restconf -l f/www-data/restconf.log -D $DBG" -s /bin/sh $WWWUSER &
|
||||
>&2 echo "clixon_restconf started"
|
||||
|
||||
# Set grp write XXX do this when creating
|
||||
chmod g+w /www-data/fastcgi_restconf.sock
|
||||
|
||||
# Start clixon backend
|
||||
>&2 echo "start clixon_backend:"
|
||||
/usr/local/sbin/clixon_backend -FD $DBG -s running -l e # logs on docker logs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue