Skip to content

Commit a78460c

Browse files
author
Michael Friedrich
authored
Merge pull request #6 from NETWAYS/feature/docker-build
Docker build environment
2 parents e89a812 + 05cb3a1 commit a78460c

File tree

8 files changed

+150
-5109
lines changed

8 files changed

+150
-5109
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Ignore all
2+
*
3+
.*
4+
5+
# Except what we need to build
6+
!/configure
7+
!/configure.ac
8+
!/install-sh
9+
!/Makefile.in
10+
!/snmp_bulkget.c
11+
!/snmp_bulkget.h
12+
!/utils.c
13+
!/utils.h

.gitignore

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Hidden files
2+
.*
3+
4+
# Prerequisites
5+
*.d
6+
7+
# Object files
8+
*.o
9+
*.ko
10+
*.obj
11+
*.elf
12+
13+
# Linker output
14+
*.ilk
15+
*.map
16+
*.exp
17+
18+
# Precompiled Headers
19+
*.gch
20+
*.pch
21+
22+
# Libraries
23+
*.lib
24+
*.a
25+
*.la
26+
*.lo
27+
28+
# Shared objects (inc. Windows DLLs)
29+
*.dll
30+
*.so
31+
*.so.*
32+
*.dylib
33+
34+
# Executables
35+
*.exe
36+
*.out
37+
*.app
38+
*.i*86
39+
*.x86_64
40+
*.hex
41+
42+
# Debug files
43+
*.dSYM/
44+
*.su
45+
*.idb
46+
*.pdb
47+
48+
# http://www.gnu.org/software/autoconf
49+
autom4te.cache
50+
/autoscan.log
51+
/autoscan-*.log
52+
/aclocal.m4
53+
/compile
54+
/config.guess
55+
/config.h.in
56+
/config.log
57+
/config.status
58+
/config.sub
59+
/configure
60+
/configure.scan
61+
/depcomp
62+
/install-sh
63+
/missing
64+
/stamp-h1
65+
66+
# https://www.gnu.org/software/libtool/
67+
/ltmain.sh
68+
69+
# http://www.gnu.org/software/texinfo
70+
/texinfo.tex
71+
72+
# http://www.gnu.org/software/m4/
73+
m4/libtool.m4
74+
m4/ltoptions.m4
75+
m4/ltsugar.m4
76+
m4/ltversion.m4
77+
m4/lt~obsolete.m4
78+
79+
# http://www.gnu.org/software/make/
80+
/Makefile

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM debian:stable-slim as builder
2+
WORKDIR /src
3+
ENV LANG="C.UTF-8"
4+
ENV TERM=xterm
5+
ARG target=""
6+
ONBUILD ENV DEBIAN_FRONTEND=noninteractive
7+
RUN apt-get update \
8+
&& apt-get install -y \
9+
build-essential \
10+
libsnmp-dev \
11+
&& rm -rf /var/lib/apt/lists/*
12+
COPY . .
13+
RUN ./configure --libexecdir=/src \
14+
&& make $target
15+
16+
FROM debian:stable-slim
17+
ONBUILD ENV DEBIAN_FRONTEND=noninteractive
18+
RUN apt-get update \
19+
&& apt-get install -y \
20+
libsnmp30 \
21+
&& rm -rf /var/lib/apt/lists/*
22+
COPY --from=0 /src/check_interfaces /check_interfaces
23+
24+
ENTRYPOINT ["/check_interfaces"]

Makefile.in

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CFLAGS=@CFLAGS@ @DEFS@
1414
# DLFLAGS=-fPIC -shared
1515
BUILDLIBS=@SNMP_LIBS@ @LIBS@
1616

17-
.PHONY: debug clean all install
17+
.PHONY: debug clean distclean all install
1818
all: build strip
1919
build: $(TARGET)
2020

@@ -28,12 +28,11 @@ debug: CFLAGS += -DDEBUG -g -O0
2828
debug: LDFLAGS += -g -O0
2929
debug: build
3030

31-
3231
clean:
33-
rm $(OBJS) $(TARGET)
32+
rm -f $(OBJS) $(TARGET)
3433

34+
distclean: clean
35+
rm -f config.log config.status Makefile
3536

3637
install: all
3738
$(INSTALL) -t $(DESTDIR) $(TARGET)
38-
39-

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ make install
3838
(see also check_interface --help)
3939

4040
check_interface -c public -h 192.168.0.1 -r 'FastEth' -p '$SERVICEPERFDATA$' -t $LASTSERVICECHECK$ -a
41-
41+
4242
Options;
4343
-h address of device
44-
44+
4545
-c|--community community (default public)
4646
-r|--regex interface list regexp
4747
Regex to match interfaces (important, this is a Regular Expression
@@ -122,3 +122,30 @@ Examples;
122122
If unsure of a pattern, you should test it on the command line thus;
123123

124124
check_interface -c public -h 192.168.0.1 -r 'Eth(0|2)$'
125+
126+
### Docker Build Environment
127+
128+
You can use docker for a development environment.
129+
130+
**Usage:**
131+
132+
Simple use:
133+
134+
```sh
135+
docker build -t check_interfaces .
136+
docker run --rm check_interfaces -c public -h sw1
137+
```
138+
139+
Persistent container
140+
141+
```sh
142+
docker build -t check_interfaces .
143+
docker create --name="check_sw1" check_interfaces -c public -h sw1
144+
docker start -a check_sw1
145+
```
146+
147+
Create a debug build
148+
149+
```sh
150+
docker build --build-arg target=debug -t check_interfaces .
151+
```

0 commit comments

Comments
 (0)