diff --git a/configure b/configure index a71a99fe..85acbab1 100755 --- a/configure +++ b/configure @@ -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 # 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/clixonrc") CONFIG_FILES="$CONFIG_FILES etc/clixonrc" ;; "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" ;; "docker/Makefile") CONFIG_FILES="$CONFIG_FILES docker/Makefile" ;; "datastore/Makefile") CONFIG_FILES="$CONFIG_FILES datastore/Makefile" ;; diff --git a/configure.ac b/configure.ac index bf9b7c3a..81f480f5 100644 --- a/configure.ac +++ b/configure.ac @@ -200,7 +200,6 @@ AC_OUTPUT(Makefile etc/Makefile etc/clixonrc example/Makefile - example/docker/Makefile extras/rpm/Makefile docker/Makefile datastore/Makefile diff --git a/doc/FAQ.md b/doc/FAQ.md index 31fa0fb8..37154618 100644 --- a/doc/FAQ.md +++ b/doc/FAQ.md @@ -102,21 +102,13 @@ You can change where CLixon looks for the configuration FILE as follows: ## Can I run Clixon as docker containers? -(Not updated) -Yes, the example works as docker containers as well. backend and cli needs a -common file-system so they need to run as a composed pair. +Yes, the example works as docker containers as well. There should be a +prepared container in docker hib for the example where the backend and +CLI is bundled. ``` - cd example/docker - make docker # Prepares /data as shared file-system mount - run.sh # Starts an example backend and a cli +sudo docker run -ti --rm olofhagsand/clixon_example ``` -The containers are by default downloaded from dockerhub, but you may -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. +Look in the example documentation for more info. ## How do I use netconf? diff --git a/docker/Dockerfile b/docker/Dockerfile index b07bc32b..2a2ce179 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -36,7 +36,11 @@ MAINTAINER Olof Hagsand ENV DEBIAN_FRONTEND noninteractive 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 # Create a directory to hold source-code, dependencies etc @@ -56,12 +60,11 @@ RUN make install # Build clixon WORKDIR /clixon/clixon RUN git checkout -b develop origin/develop -RUN ./configure --without-restconf +RUN ./configure RUN make RUN make install RUN make install-include -#RUN rm -rf /clixon RUN ldconfig diff --git a/example/docker/Makefile.in b/example/Dockerfile similarity index 58% rename from example/docker/Makefile.in rename to example/Dockerfile index 492c727f..24403dc5 100644 --- a/example/docker/Makefile.in +++ b/example/Dockerfile @@ -30,51 +30,32 @@ # # ***** 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 -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,... -.PHONY: docker push -docker: $(APPNAME).conf - install -d data - install -d data/yang - install -d data/backend - install -d data/cli - install -d data/netconf - 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 +# Build clixon +WORKDIR /example/clixon +RUN git checkout -b develop origin/develop +RUN ./configure +WORKDIR /example/clixon/example +RUN make +RUN make install +RUN install example.xml /usr/local/etc/clixon.xml -clean: - rm -f $(APPNAME).conf +CMD /usr/local/sbin/clixon_backend && /usr/local/bin/clixon_cli -distclean: clean - rm -f Makefile *~ .depend - rm -rf data -install: -uninstall: -install-include: - -depend: - $(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend - -#include .depend diff --git a/example/Makefile.in b/example/Makefile.in index ac5f73d6..336968bf 100644 --- a/example/Makefile.in +++ b/example/Makefile.in @@ -51,6 +51,9 @@ CLI_PLUGIN = $(APPNAME)_cli.so NETCONF_PLUGIN = $(APPNAME)_netconf.so RESTCONF_PLUGIN = $(APPNAME)_restconf.so +# Example docker image +IMAGE = olofhagsand/clixon_example + PLUGINS = $(BE_PLUGIN) $(BE2_PLUGIN) $(CLI_PLUGIN) $(NETCONF_PLUGIN) $(RESTCONF_PLUGIN) all: $(PLUGINS) @@ -106,11 +109,9 @@ OBJS = $(BE_OBJ) $(BE2_OBJ) $(CLI_OBJ) $(NETCONF_OBJ) $(RESTCONF_OBJ) clean: rm -f $(PLUGINS) $(OBJS) - (cd docker && $(MAKE) $(MFLAGS) $@) distclean: clean rm -f Makefile *~ .depend - (cd docker && $(MAKE) $(MFLAGS) $@) install: $(YANGSPECS) $(CLISPECS) $(BE_PLUGIN) $(BE2_PLUGIN) $(CLI_PLUGIN) $(NETCONF_PLUGIN) $(RESTCONF_PLUGIN) $(APPNAME).xml 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 -m 0644 $(CLISPECS) $(DESTDIR)$(clixon_LIBDIR)/clispec install -d -m 0755 $(DESTDIR)$(clixon_LOCALSTATEDIR) - (cd docker && $(MAKE) $(MFLAGS) $@) + +docker: + sudo docker build -t $(IMAGE) . + +push: + sudo docker push $(IMAGE) + uninstall: rm -rf $(DESTDIR)$(clixon_SYSCONFDIR)/$(APPNAME).xml rm -rf $(DESTDIR)$(clixon_DBSPECDIR) rm -rf $(DESTDIR)$(clixon_LOCALSTATEDIR) rm -rf $(DESTDIR)$(clixon_LIBDIR) - (cd docker && $(MAKE) $(MFLAGS) $@) install-include: depend: $(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend - (cd docker && $(MAKE) $(MFLAGS) $@) #include .depend diff --git a/example/README.md b/example/README.md index be751154..c2368c2f 100644 --- a/example/README.md +++ b/example/README.md @@ -204,5 +204,19 @@ cd docker # 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 +``` + diff --git a/example/docker/README b/example/docker/README deleted file mode 100644 index 2d93a6a9..00000000 --- a/example/docker/README +++ /dev/null @@ -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 diff --git a/example/docker/routing.conf.local b/example/docker/routing.conf.local deleted file mode 100644 index a5f96dd2..00000000 --- a/example/docker/routing.conf.local +++ /dev/null @@ -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: -# [@] -# This option is only relevant if CLICON_DBSPEC_TYPE is YANG -# CLICON_YANG_MODULE_MAIN clicon -# Option used to construct initial yang file: -# [@] -# 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: -# [@] -# This option is only relevant if CLICON_DBSPEC_TYPE is YANG -CLICON_YANG_MODULE_MAIN ietf-ip - -# Option used to construct initial yang file: -# [@] -# 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 diff --git a/example/docker/run.sh b/example/docker/run.sh deleted file mode 100755 index 295d5d4e..00000000 --- a/example/docker/run.sh +++ /dev/null @@ -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 - -