Skip to content

Commit 37c89a5

Browse files
committed
Remade docker example to be more generic
1 parent b658775 commit 37c89a5

File tree

7 files changed

+48
-20
lines changed

7 files changed

+48
-20
lines changed

docker/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
This directory contains sub-directories with examples of Clixon docker images:
44

5-
* [example](example/README.md) Clixon main example image
5+
* [example](example/README.md) Clixon main example / generic YANG
66
* [clixon-dev](clixon-dev/README.md) Clixon development image
7-
* [test](test/README.md) Test scripts used in upstream CI
7+
* [test](test/README.md) Test scripts used in upstream CI
88

99

docker/example/Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# ***** BEGIN LICENSE BLOCK *****
3-
#
3+
#
44
# Copyright (C) 2017-2019 Olof Hagsand
55
# Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
66
#
@@ -23,7 +23,7 @@
2323
# in which case the provisions of the GPL are applicable instead
2424
# of those above. If you wish to allow use of your version of this file only
2525
# under the terms of the GPL, and not to allow others to
26-
# use your version of this file under the terms of Apache License version 2,
26+
# use your version of this file under the terms of Apache License version 2,
2727
# indicate your decision by deleting the provisions above and replace them with
2828
# the notice and other provisions required by the GPL. If you do not delete
2929
# the provisions above, a recipient may use your version of this file under
@@ -79,14 +79,18 @@ RUN make DESTDIR=/clixon/build install-include
7979
WORKDIR /clixon/clixon/example/main
8080
RUN make
8181
RUN make DESTDIR=/clixon/build install
82-
RUN mkdir -p /clixon/build/etc
83-
RUN install example.xml /clixon/build/etc/clixon.xml
82+
RUN mkdir -p /clixon/build/usr/local/etc/clixon
83+
RUN mkdir -p /clixon/build/usr/local/etc/clixon/example
84+
RUN install example.xml /clixon/build/usr/local/etc/clixon/example.xml
8485

8586
# Copy startscript
8687
WORKDIR /clixon
87-
COPY startsystem.sh startsystem.sh
88+
COPY startsystem.sh startsystem.sh
8889
RUN install startsystem.sh /clixon/build/usr/local/bin/
8990

91+
WORKDIR /clixon/build/usr/local/share/clixon
92+
COPY yang/ example/
93+
9094
#
9195
# Stage 2
9296
# The second step skips the development environment and builds a runtime system
@@ -135,9 +139,8 @@ RUN echo -n 'admin:admin' | chpasswd
135139
COPY --from=0 /clixon/build/ /
136140

137141
# Overwrite config file since install dirs are wrong
138-
COPY example.xml /usr/local/etc/clixon/example.xml
139142
# Create symlink so you can run clixon without -f arg
140-
RUN ln -s /usr/local/etc/clixon/example.xml /usr/local/etc/clixon.xml
143+
RUN ln -s /usr/local/etc/clixon/example.xml /etc/clixon.xml
141144

142145
# Start daemons
143146
CMD /usr/local/bin/startsystem.sh

docker/example/Makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ CFLAGS = @CFLAGS@
3939
LDFLAGS = @LDFLAGS@
4040
LIBS = @LIBS@
4141

42+
#DOCKERFLAGS="--no-cache"
43+
4244
# docker.hub image. CHANGE THIS IF YOU PUSH YOUR OWN
4345
IMG = clixon/clixon-example
4446

@@ -78,4 +80,3 @@ install-include:
7880
install:
7981

8082
uninstall:
81-

docker/example/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,18 @@ You may also do `make push` if you want to push the image, but you may then cons
5353

5454
(You may have to login for push with sudo docker login -u <username>)
5555

56-
## Other YANGs
56+
## Modification
57+
58+
You can modify the example container with your own YANGs, keys, config-file and startup-db
59+
60+
Yangs: Create a dir yang/ in this dir and add your yang files to it
61+
62+
Key: Start the container with SSHKEY=<your pubkey> ./start.sh
63+
64+
exmaple.xml: Place a file called "example.xml" in this dir.
65+
66+
Startup: Place a file called "startup_db" in this dir.
5767

58-
You can add other YANGs for experimentation by:
5968
```
6069
$ sudo docker cp myyangs.tgz clixon-example:/usr/local/share/clixon/example
6170
```

docker/example/start.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# ***** BEGIN LICENSE BLOCK *****
3-
#
3+
#
44
# Copyright (C) 2017-2019 Olof Hagsand
55
# Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
66
#
@@ -23,7 +23,7 @@
2323
# in which case the provisions of the GPL are applicable instead
2424
# of those above. If you wish to allow use of your version of this file only
2525
# under the terms of the GPL, and not to allow others to
26-
# use your version of this file under the terms of Apache License version 2,
26+
# use your version of this file under the terms of Apache License version 2,
2727
# indicate your decision by deleting the provisions above and replace them with
2828
# the notice and other provisions required by the GPL. If you do not delete
2929
# the provisions above, a recipient may use your version of this file under
@@ -45,16 +45,30 @@ set -eux
4545

4646
sudo docker kill $NAME || true 2> /dev/null # ignore errors
4747

48+
4849
# Start clixon-example backend
4950
sudo docker run --name ${NAME} --rm -td clixon/clixon-example #|| err "Error starting clixon-example"
5051

51-
# Copy rsa pubkey
52+
# Copy user rsa pubkey
5253
if [ -n "$SSHKEY" ]; then
53-
# install user pub key
54+
# install user pub key
5455
sudo docker exec -it $NAME mkdir -m 700 /root/.ssh
5556
sudo docker cp $SSHKEY $NAME:/root/.ssh/authorized_keys
5657
sudo docker exec -it $NAME chown root /root/.ssh/authorized_keys
5758
sudo docker exec -it $NAME chgrp root /root/.ssh/authorized_keys
5859
fi
5960

61+
#if [ -d yang ]; then
62+
# for f in $(ls yang/*.yang); do
63+
# sudo docker cp $f $NAME:/usr/local/share/clixon/example/
64+
# done
65+
#fi
66+
if [ -f startup_db ]; then
67+
sudo docker cp startup_db $NAME:/usr/local/var/example/
68+
fi
69+
if [ -f example.xml ]; then
70+
sudo docker cp example.xml $NAME:/usr/local/etc/clixon/
71+
fi
72+
73+
6074
>&2 echo "$NAME started"

docker/example/startsystem.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22
# ***** BEGIN LICENSE BLOCK *****
3-
#
3+
#
44
# Copyright (C) 2017-2019 Olof Hagsand
55
# Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
66
#
@@ -23,7 +23,7 @@
2323
# in which case the provisions of the GPL are applicable instead
2424
# of those above. If you wish to allow use of your version of this file only
2525
# under the terms of the GPL, and not to allow others to
26-
# use your version of this file under the terms of Apache License version 2,
26+
# use your version of this file under the terms of Apache License version 2,
2727
# indicate your decision by deleting the provisions above and replace them with
2828
# the notice and other provisions required by the GPL. If you do not delete
2929
# the provisions above, a recipient may use your version of this file under
@@ -54,8 +54,8 @@ touch /run/openrc/softlevel
5454
#/usr/local/bin/clixon_restconf -l f/var/log/restconf.log -D $DBG &
5555
#>&2 echo "clixon_restconf started"
5656

57-
# Start clixon backend
58-
/usr/local/sbin/clixon_backend -D $DBG -s running -l e -f /usr/local/etc/clixon/example.xml
57+
# Start clixon backend
58+
/usr/local/sbin/clixon_backend -D $DBG -s startup -l e -f /usr/local/etc/clixon/example.xml
5959
>&2 echo "clixon_backend started"
6060

6161
# Alt: let backend be in foreground, but test scripts may

docker/example/yang/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Place extra YANGs here

0 commit comments

Comments
 (0)