* 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:
Olof Hagsand 2019-02-13 21:33:40 +01:00
parent 9fc8ac2e8e
commit d64d433468
58 changed files with 579 additions and 538 deletions

View file

@ -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

View file

@ -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:

View file

@ -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:

View file

@ -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