* 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"
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue