docker update

This commit is contained in:
Olof Hagsand 2018-07-21 17:01:56 +00:00
parent c7aed5e7a7
commit 3a39b0361a
10 changed files with 55 additions and 143 deletions

3
configure vendored
View file

@ -4325,7 +4325,7 @@ _ACEOF
ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile example/docker/Makefile extras/rpm/Makefile docker/Makefile datastore/Makefile datastore/text/Makefile util/Makefile yang/Makefile doc/Makefile" ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile extras/rpm/Makefile docker/Makefile datastore/Makefile datastore/text/Makefile util/Makefile yang/Makefile doc/Makefile"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
@ -5032,7 +5032,6 @@ do
"etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;; "etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;;
"etc/clixonrc") CONFIG_FILES="$CONFIG_FILES etc/clixonrc" ;; "etc/clixonrc") CONFIG_FILES="$CONFIG_FILES etc/clixonrc" ;;
"example/Makefile") CONFIG_FILES="$CONFIG_FILES example/Makefile" ;; "example/Makefile") CONFIG_FILES="$CONFIG_FILES example/Makefile" ;;
"example/docker/Makefile") CONFIG_FILES="$CONFIG_FILES example/docker/Makefile" ;;
"extras/rpm/Makefile") CONFIG_FILES="$CONFIG_FILES extras/rpm/Makefile" ;; "extras/rpm/Makefile") CONFIG_FILES="$CONFIG_FILES extras/rpm/Makefile" ;;
"docker/Makefile") CONFIG_FILES="$CONFIG_FILES docker/Makefile" ;; "docker/Makefile") CONFIG_FILES="$CONFIG_FILES docker/Makefile" ;;
"datastore/Makefile") CONFIG_FILES="$CONFIG_FILES datastore/Makefile" ;; "datastore/Makefile") CONFIG_FILES="$CONFIG_FILES datastore/Makefile" ;;

View file

@ -200,7 +200,6 @@ AC_OUTPUT(Makefile
etc/Makefile etc/Makefile
etc/clixonrc etc/clixonrc
example/Makefile example/Makefile
example/docker/Makefile
extras/rpm/Makefile extras/rpm/Makefile
docker/Makefile docker/Makefile
datastore/Makefile datastore/Makefile

View file

@ -102,21 +102,13 @@ You can change where CLixon looks for the configuration FILE as follows:
## Can I run Clixon as docker containers? ## Can I run Clixon as docker containers?
(Not updated) Yes, the example works as docker containers as well. There should be a
Yes, the example works as docker containers as well. backend and cli needs a prepared container in docker hib for the example where the backend and
common file-system so they need to run as a composed pair. CLI is bundled.
``` ```
cd example/docker sudo docker run -ti --rm olofhagsand/clixon_example
make docker # Prepares /data as shared file-system mount
run.sh # Starts an example backend and a cli
``` ```
The containers are by default downloaded from dockerhub, but you may Look in the example documentation for more info.
build the containers locally:
```
cd docker
make docker
```
You may also push the containers with 'make push' but you may then consider changing the image name in the makefile.
## How do I use netconf? ## How do I use netconf?

View file

@ -36,7 +36,11 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git make gcc flex bison git make gcc flex bison \
libfcgi-dev \
libcurl4-openssl-dev
RUN groupadd clicon RUN groupadd clicon
# Create a directory to hold source-code, dependencies etc # Create a directory to hold source-code, dependencies etc
@ -56,12 +60,11 @@ RUN make install
# Build clixon # Build clixon
WORKDIR /clixon/clixon WORKDIR /clixon/clixon
RUN git checkout -b develop origin/develop RUN git checkout -b develop origin/develop
RUN ./configure --without-restconf RUN ./configure
RUN make RUN make
RUN make install RUN make install
RUN make install-include RUN make install-include
#RUN rm -rf /clixon
RUN ldconfig RUN ldconfig

View file

@ -30,51 +30,32 @@
# #
# ***** END LICENSE BLOCK ***** # ***** END LICENSE BLOCK *****
# #
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
prefix = @prefix@
bindir = @bindir@
includedir = @includedir@
datarootdir = @datarootdir@
APPNAME = routing FROM olofhagsand/clixon
MAINTAINER Olof Hagsand <olof@hagsand.se>
all: $(APPNAME).conf RUN apt-get update && apt-get install -y \
procps # ps for debugging
# Create a directory to hold source-code, dependencies etc
RUN mkdir /example
WORKDIR /example
-include $(DESTDIR)$(datarootdir)/clixon/clixon.mk # Clone clixon (again) since example application is there.
# Replace this with your application
RUN git clone https://github.com/clicon/clixon.git
# Kind of reverse install, could have copied from src dir,... # Build clixon
.PHONY: docker push WORKDIR /example/clixon
docker: $(APPNAME).conf RUN git checkout -b develop origin/develop
install -d data RUN ./configure
install -d data/yang WORKDIR /example/clixon/example
install -d data/backend RUN make
install -d data/cli RUN make install
install -d data/netconf RUN install example.xml /usr/local/etc/clixon.xml
install -d data/clispec
install $(APPNAME).conf data/clixon.conf # docker image assumes /data/clixon.conf
install ../*.yang data/yang/
install ../routing_cli.so data/cli/
install ../routing_backend.so data/backend/
install ../routing_netconf.so data/netconf/
install ../*.cli data/clispec
clean: CMD /usr/local/sbin/clixon_backend && /usr/local/bin/clixon_cli
rm -f $(APPNAME).conf
distclean: clean
rm -f Makefile *~ .depend
rm -rf data
install:
uninstall:
install-include:
depend:
$(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend
#include .depend

View file

@ -51,6 +51,9 @@ CLI_PLUGIN = $(APPNAME)_cli.so
NETCONF_PLUGIN = $(APPNAME)_netconf.so NETCONF_PLUGIN = $(APPNAME)_netconf.so
RESTCONF_PLUGIN = $(APPNAME)_restconf.so RESTCONF_PLUGIN = $(APPNAME)_restconf.so
# Example docker image
IMAGE = olofhagsand/clixon_example
PLUGINS = $(BE_PLUGIN) $(BE2_PLUGIN) $(CLI_PLUGIN) $(NETCONF_PLUGIN) $(RESTCONF_PLUGIN) PLUGINS = $(BE_PLUGIN) $(BE2_PLUGIN) $(CLI_PLUGIN) $(NETCONF_PLUGIN) $(RESTCONF_PLUGIN)
all: $(PLUGINS) all: $(PLUGINS)
@ -106,11 +109,9 @@ OBJS = $(BE_OBJ) $(BE2_OBJ) $(CLI_OBJ) $(NETCONF_OBJ) $(RESTCONF_OBJ)
clean: clean:
rm -f $(PLUGINS) $(OBJS) rm -f $(PLUGINS) $(OBJS)
(cd docker && $(MAKE) $(MFLAGS) $@)
distclean: clean distclean: clean
rm -f Makefile *~ .depend rm -f Makefile *~ .depend
(cd docker && $(MAKE) $(MFLAGS) $@)
install: $(YANGSPECS) $(CLISPECS) $(BE_PLUGIN) $(BE2_PLUGIN) $(CLI_PLUGIN) $(NETCONF_PLUGIN) $(RESTCONF_PLUGIN) $(APPNAME).xml install: $(YANGSPECS) $(CLISPECS) $(BE_PLUGIN) $(BE2_PLUGIN) $(CLI_PLUGIN) $(NETCONF_PLUGIN) $(RESTCONF_PLUGIN) $(APPNAME).xml
install -d -m 0755 $(DESTDIR)$(clixon_SYSCONFDIR) install -d -m 0755 $(DESTDIR)$(clixon_SYSCONFDIR)
@ -128,20 +129,24 @@ install: $(YANGSPECS) $(CLISPECS) $(BE_PLUGIN) $(BE2_PLUGIN) $(CLI_PLUGIN) $(NET
install -d -m 0755 $(DESTDIR)$(clixon_LIBDIR)/clispec install -d -m 0755 $(DESTDIR)$(clixon_LIBDIR)/clispec
install -m 0644 $(CLISPECS) $(DESTDIR)$(clixon_LIBDIR)/clispec install -m 0644 $(CLISPECS) $(DESTDIR)$(clixon_LIBDIR)/clispec
install -d -m 0755 $(DESTDIR)$(clixon_LOCALSTATEDIR) install -d -m 0755 $(DESTDIR)$(clixon_LOCALSTATEDIR)
(cd docker && $(MAKE) $(MFLAGS) $@)
docker:
sudo docker build -t $(IMAGE) .
push:
sudo docker push $(IMAGE)
uninstall: uninstall:
rm -rf $(DESTDIR)$(clixon_SYSCONFDIR)/$(APPNAME).xml rm -rf $(DESTDIR)$(clixon_SYSCONFDIR)/$(APPNAME).xml
rm -rf $(DESTDIR)$(clixon_DBSPECDIR) rm -rf $(DESTDIR)$(clixon_DBSPECDIR)
rm -rf $(DESTDIR)$(clixon_LOCALSTATEDIR) rm -rf $(DESTDIR)$(clixon_LOCALSTATEDIR)
rm -rf $(DESTDIR)$(clixon_LIBDIR) rm -rf $(DESTDIR)$(clixon_LIBDIR)
(cd docker && $(MAKE) $(MFLAGS) $@)
install-include: install-include:
depend: depend:
$(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend $(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend
(cd docker && $(MAKE) $(MFLAGS) $@)
#include .depend #include .depend

View file

@ -204,5 +204,19 @@ cd docker
# look in README # look in README
``` ```
## Docker
Run the example as a docker container as follows:
```
sudo docker run -ti --rm olofhagsand/clixon_example
```
Build the container and push yourself: First change the IMAGE variable in Makefile (eg to "you/clixon_example). Then build and push:
```
make docker
make push
sudo docker run -ti --rm you/clixon_example
```

View file

@ -1,7 +0,0 @@
Run the ietf routing example as docker container.
Use the dockerhub container, or alternatively, build clicon as docker images
by doing make docker in the top builddir.
(cd ..; make) # Make example
make docker # Create config file and shared file system
run.sh # Run a backend and a cli container

View file

@ -1,66 +0,0 @@
# Main YANG module first parsed by parser (in CLICON_YANG_DIR). eg clicon.yang.
# Location of configuration-file for default values (this file)
CLICON_CONFIGFILE /data/clixon.conf
# Location of YANG module and submodule files. Only if CLICON_DBSPEC_TYPE is YANG
CLICON_YANG_DIR /data/yang
# Option used to construct initial yang file:
# <module>[@<revision>]
# This option is only relevant if CLICON_DBSPEC_TYPE is YANG
# CLICON_YANG_MODULE_MAIN clicon
# Option used to construct initial yang file:
# <module>[@<revision>]
# This option is only relevant if CLICON_DBSPEC_TYPE is YANG
CLICON_YANG_MODULE_REVISION
# Candidate qdbm database
CLICON_CANDIDATE_DB /data/candidate_db
# Running qdbm database
CLICON_RUNNING_DB /data/running_db
# Location of backend .so plugins
CLICON_BACKEND_DIR /data/backend
# Location of netconf (frontend) .so plugins
CLICON_NETCONF_DIR /data/netconf
# Location of cli frontend .so plugins
CLICON_CLI_DIR /data/cli
# Location of frontend .cli cligen spec files
CLICON_CLISPEC_DIR /data/clispec
# Directory where to save configuration commit history (in XML). Snapshots
# are saved chronologically
CLICON_ARCHIVE_DIR /data
# XXX Name of startup configuration file (in XML)
CLICON_STARTUP_CONFIG /data/startup-config
# Address family for communicating with clixon_backend (UNIX|IPv4|IPv6)
CLICON_SOCK_FAMILY UNIX
# If family above is AF_UNIX: Unix socket for communicating with clixon_backend
# If family above is AF_INET: IPv4 address
CLICON_SOCK /data/routing.sock
# Inet socket port for communicating with clixon_backend (only IPv4|IPv6)
CLICON_SOCK_PORT 4535
# Process-id file
CLICON_BACKEND_PIDFILE /data/routing.pidfile
# Save values as XML in database instead of lvec:s.
# This is optimized for yang specified applications
# But not compatible with key-based application (eg Rost)
CLICON_DB_XML 1
# Startup CLI mode. This should match the CLICON_MODE in your startup clispec file
CLICON_CLI_MODE routing
# Option used to construct initial yang file:
# <module>[@<revision>]
# This option is only relevant if CLICON_DBSPEC_TYPE is YANG
CLICON_YANG_MODULE_MAIN ietf-ip
# Option used to construct initial yang file:
# <module>[@<revision>]
# This option is only relevant if CLICON_DBSPEC_TYPE is YANG
CLICON_YANG_MODULE_REVISION 2014-06-16
# Generate code for CLI completion of existing db symbols
# CLICON_CLI_GENMODEL_COMPLETION 0
CLICON_CLI_GENMODEL_COMPLETION 1
# How to generate and show CLI syntax: VARS|ALL
# CLICON_CLI_GENMODEL_TYPE VARS
CLICON_CLI_GENMODEL_TYPE VARS

View file

@ -1,8 +0,0 @@
#!/bin/bash
# Start daemon and a cli docker containers .
# Note that they have a common file-system at /data
#
sudo docker run -td --net host -v $(pwd)/data:/data olofhagsand/clixon_backend
sudo docker run -ti --rm --net host -v $(pwd)/data:/data olofhagsand/clixon_cli