File tree 4 files changed +26
-17
lines changed
4 files changed +26
-17
lines changed Original file line number Diff line number Diff line change 1
1
FROM debian:10-slim as build
2
2
3
- ENV USER="casperklein"
4
- ENV NAME="netbox-scanner"
5
- ENV VERSION="2.0.0"
6
-
7
3
ENV PACKAGES="python3 python3-pip nmap"
8
4
5
+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
6
+
9
7
ENV GIT_USER="lopes"
10
8
ENV GIT_REPO="netbox-scanner"
11
9
ENV GIT_COMMIT="af65c252776127d2ab3505862fca7670e299c45c"
12
10
ENV GIT_ARCHIVE="https://github.com/$GIT_USER/$GIT_REPO/archive/$GIT_COMMIT.tar.gz"
13
11
14
12
# Install packages
13
+ ENV DEBIAN_FRONTEND=noninteractive
15
14
RUN apt-get update \
15
+ && apt-get -y upgrade \
16
16
&& apt-get -y install $PACKAGES \
17
17
&& rm -rf /var/lib/apt/lists/*
18
18
Original file line number Diff line number Diff line change 1
1
# all targets are phony (no files to check)
2
2
.PHONY : build clean scan push
3
3
4
- USER := $(shell grep -P 'ENV\s+USER=".+?"' Dockerfile | cut -d'"' -f2)
5
- NAME := $(shell grep -P 'ENV\s+NAME=".+?"' Dockerfile | cut -d'"' -f2)
6
- VERSION := $(shell grep -P 'ENV\s+VERSION=".+?"' Dockerfile | cut -d'"' -f2)
4
+ SHELL = /bin/bash
5
+
6
+ IMAGE := $(shell jq -er '.image' < config.json)
7
+ TAG := $(shell jq -er '"\(.image) :\(.version)"' < config.json)
7
8
8
9
build :
9
10
@./build.sh
10
11
11
12
clean :
12
- docker rmi $(USER ) /$(NAME ) :$(VERSION )
13
+ @echo " Removing Docker images.."
14
+ docker rmi " $( TAG) " ; \
15
+ docker rmi " $( IMAGE) :latest"
13
16
14
17
scan :
15
18
@./scan.sh
16
19
17
20
push :
18
- docker push $(USER ) /$(NAME ) :$(VERSION )
19
- docker push $(USER ) /$(NAME ) :latest
21
+ @echo " Pushing image to Docker Hub.."
22
+ docker push " $( TAG) "
23
+ docker push " $( IMAGE) :latest"
Original file line number Diff line number Diff line change 2
2
3
3
set -ueo pipefail
4
4
5
- USER=$( grep -P ' ENV\s+USER=".+?"' Dockerfile | cut -d' "' -f2)
6
- NAME=$( grep -P ' ENV\s+NAME=".+?"' Dockerfile | cut -d' "' -f2)
7
- VERSION=$( grep -P ' ENV\s+VERSION=".+?"' Dockerfile | cut -d' "' -f2)
8
- TAG=" $USER /$NAME :$VERSION "
5
+ VERSION=$( jq -er ' .version' < config.json)
6
+ IMAGE=$( jq -er ' .image' < config.json)
7
+ TAG=$( jq -er ' "\(.image):\(.version)"' < config.json)
9
8
10
9
DIR=${0%/* }
11
10
cd " $DIR "
12
11
13
- echo " Building: $NAME $VERSION "
12
+ echo " Building: $TAG "
14
13
echo
15
- docker build -t " $TAG " .
16
- docker tag " $TAG " " $USER / $NAME :latest"
14
+ docker build -t " $TAG " --build-arg VERSION= " $VERSION " .
15
+ docker tag " $TAG " " $IMAGE :latest"
Original file line number Diff line number Diff line change
1
+ {
2
+ "user" : " casperklein" ,
3
+ "name" : " netbox-scanner" ,
4
+ "image" : " casperklein/netbox-scanner" ,
5
+ "version" : " 2.0.0"
6
+ }
You can’t perform that action at this time.
0 commit comments