@@ -6,96 +6,129 @@ echo "▶️ $0 $*"
66set -e
77
88if [ " ${1} x" == " x" ] || [ " ${1} " == " --help" ] || [ " ${1} " == " -h" ]; then
9- echo " Usage: ${0} <branch> [--push]"
10- echo " branch The branch or tag to build. Required."
11- echo " --push Pushes the built Docker image to the registry."
12- echo " "
13- echo " You can use the following ENV variables to customize the build:"
14- echo " SRC_ORG Which fork of netbox to use (i.e. github.com/\$ {SRC_ORG}/\$ {SRC_REPO})."
15- echo " Default: netbox-community"
16- echo " SRC_REPO The name of the repository to use (i.e. github.com/\$ {SRC_ORG}/\$ {SRC_REPO})."
17- echo " Default: netbox"
18- echo " URL Where to fetch the code from."
19- echo " Must be a git repository. Can be private."
20- echo " Default: https://github.com/\$ {SRC_ORG}/\$ {SRC_REPO}.git"
21- echo " NETBOX_PATH The path where netbox will be checkout out."
22- echo " Must not be outside of the netbox-docker repository (because of Docker)!"
23- echo " Default: .netbox"
24- echo " SKIP_GIT If defined, git is not invoked and \$ {NETBOX_PATH} will not be altered."
25- echo " This may be useful, if you are manually managing the NETBOX_PATH."
26- echo " Default: undefined"
27- echo " TAG The version part of the docker tag."
28- echo " Default:"
29- echo " When <branch>=master: latest"
30- echo " When <branch>=develop: snapshot"
31- echo " Else: same as <branch>"
32- echo " IMAGE_NAMES The names used for the image including the registry"
33- echo " Used for tagging the image."
34- echo " Default: docker.io/netboxcommunity/netbox"
35- echo " Example: 'docker.io/netboxcommunity/netbox quay.io/netboxcommunity/netbox'"
36- echo " DOCKER_TAG The name of the tag which is applied to the image."
37- echo " Useful for pushing into another registry than hub.docker.com."
38- echo " Default: \$ {DOCKER_REGISTRY}/\$ {DOCKER_ORG}/\$ {DOCKER_REPO}:\$ {TAG}"
39- echo " DOCKER_SHORT_TAG The name of the short tag which is applied to the"
40- echo " image. This is used to tag all patch releases to their"
41- echo " containing version e.g. v2.5.1 -> v2.5"
42- echo " Default: \$ {DOCKER_REGISTRY}/\$ {DOCKER_ORG}/\$ {DOCKER_REPO}:<MAJOR>.<MINOR>"
43- echo " DOCKERFILE The name of Dockerfile to use."
44- echo " Default: Dockerfile"
45- echo " DOCKER_FROM The base image to use."
46- echo " Default: 'ubuntu:22.04'"
47- echo " BUILDX_PLATFORMS"
48- echo " Specifies the platform(s) to build the image for."
49- echo " Example: 'linux/amd64,linux/arm64'"
50- echo " Default: 'linux/amd64'"
51- echo " BUILDX_BUILDER_NAME"
52- echo " If defined, the image build will be assigned to the given builder."
53- echo " If you specify this variable, make sure that the builder exists."
54- echo " If this value is not defined, a new builx builder with the directory name of the"
55- echo " current directory (i.e. '$( basename " ${PWD} " ) ') is created."
56- echo " Example: 'clever_lovelace'"
57- echo " Default: undefined"
58- echo " BUILDX_REMOVE_BUILDER"
59- echo " If defined (and only if BUILDX_BUILDER_NAME is undefined),"
60- echo " then the buildx builder created by this script will be removed after use."
61- echo " This is useful if you build NetBox Docker on an automated system that does"
62- echo " not manage the builders for you."
63- echo " Example: 'on'"
64- echo " Default: undefined"
65- echo " HTTP_PROXY The proxy to use for http requests."
66- echo " Example: http://proxy.domain.tld:3128"
67- echo " Default: undefined"
68- echo " NO_PROXY Comma-separated list of domain extensions proxy should not be used for."
69- echo " Example: .domain1.tld,.domain2.tld"
70- echo " Default: undefined"
71- echo " DEBUG If defined, the script does not stop when certain checks are unsatisfied."
72- echo " Default: undefined"
73- echo " DRY_RUN Prints all build statements instead of running them."
74- echo " Default: undefined"
75- echo " GH_ACTION If defined, special 'echo' statements are enabled that set the"
76- echo " following environment variables in Github Actions:"
77- echo " - FINAL_DOCKER_TAG: The final value of the DOCKER_TAG env variable"
78- echo " Default: undefined"
79- echo " "
80- echo " Examples:"
81- echo " ${0} master"
82- echo " This will fetch the latest 'master' branch, build a Docker Image and tag it"
83- echo " 'netboxcommunity/netbox:latest'."
84- echo " ${0} develop"
85- echo " This will fetch the latest 'develop' branch, build a Docker Image and tag it"
86- echo " 'netboxcommunity/netbox:snapshot'."
87- echo " ${0} v2.6.6"
88- echo " This will fetch the 'v2.6.6' tag, build a Docker Image and tag it"
89- echo " 'netboxcommunity/netbox:v2.6.6' and 'netboxcommunity/netbox:v2.6'."
90- echo " ${0} develop-2.7"
91- echo " This will fetch the 'develop-2.7' branch, build a Docker Image and tag it"
92- echo " 'netboxcommunity/netbox:develop-2.7'."
93- echo " SRC_ORG=cimnine ${0} feature-x"
94- echo " This will fetch the 'feature-x' branch from https://github.com/cimnine/netbox.git,"
95- echo " build a Docker Image and tag it 'netboxcommunity/netbox:feature-x'."
96- echo " SRC_ORG=cimnine DOCKER_ORG=cimnine ${0} feature-x"
97- echo " This will fetch the 'feature-x' branch from https://github.com/cimnine/netbox.git,"
98- echo " build a Docker Image and tag it 'cimnine/netbox:feature-x'."
9+ _BOLD=$( tput bold)
10+ _GREEN=$( tput setaf 2)
11+ _CYAN=$( tput setaf 6)
12+ _CLEAR=$( tput sgr0)
13+
14+ cat << END_OF_HELP
15+ ${_BOLD} Usage:${_CLEAR} ${0} <branch> [--push]
16+
17+ branch The branch or tag to build. Required.
18+ --push Pushes the built container image to the registry.
19+
20+ ${_BOLD} You can use the following ENV variables to customize the build:${_CLEAR}
21+
22+ SRC_ORG Which fork of netbox to use (i.e. github.com/\$ {SRC_ORG}/\$ {SRC_REPO}).
23+ ${_GREEN} Default:${_CLEAR} netbox-community
24+
25+ SRC_REPO The name of the repository to use (i.e. github.com/\$ {SRC_ORG}/\$ {SRC_REPO}).
26+ ${_GREEN} Default:${_CLEAR} netbox
27+
28+ URL Where to fetch the code from.
29+ Must be a git repository. Can be private.
30+ ${_GREEN} Default:${_CLEAR} https://github.com/\$ {SRC_ORG}/\$ {SRC_REPO}.git
31+
32+ NETBOX_PATH The path where netbox will be checkout out.
33+ Must not be outside of the netbox-docker repository (because of Docker)!
34+ ${_GREEN} Default:${_CLEAR} .netbox
35+
36+ SKIP_GIT If defined, git is not invoked and \$ {NETBOX_PATH} will not be altered.
37+ This may be useful, if you are manually managing the NETBOX_PATH.
38+ ${_GREEN} Default:${_CLEAR} undefined
39+
40+ TAG The version part of the image tag.
41+ ${_GREEN} Default:${_CLEAR}
42+ When <branch>=master: latest
43+ When <branch>=develop: snapshot
44+ Else: same as <branch>
45+
46+ IMAGE_NAMES The names used for the image including the registry
47+ Used for tagging the image.
48+ ${_GREEN} Default:${_CLEAR} docker.io/netboxcommunity/netbox
49+ ${_CYAN} Example:${_CLEAR} 'docker.io/netboxcommunity/netbox quay.io/netboxcommunity/netbox'
50+
51+ DOCKER_TAG The name of the tag which is applied to the image.
52+ Useful for pushing into another registry than hub.docker.com.
53+ ${_GREEN} Default:${_CLEAR} \$ {DOCKER_REGISTRY}/\$ {DOCKER_ORG}/\$ {DOCKER_REPO}:\$ {TAG}
54+
55+ DOCKER_SHORT_TAG The name of the short tag which is applied to the
56+ image. This is used to tag all patch releases to their
57+ containing version e.g. v2.5.1 -> v2.5
58+ ${_GREEN} Default:${_CLEAR} \$ {DOCKER_REGISTRY}/\$ {DOCKER_ORG}/\$ {DOCKER_REPO}:<MAJOR>.<MINOR>
59+
60+ DOCKERFILE The name of Dockerfile to use.
61+ ${_GREEN} Default:${_CLEAR} Dockerfile
62+
63+ DOCKER_FROM The base image to use.
64+ ${_GREEN} Default:${_CLEAR} 'ubuntu:22.04'
65+
66+ BUILDX_PLATFORMS
67+ Specifies the platform(s) to build the image for.
68+ ${_CYAN} Example:${_CLEAR} 'linux/amd64,linux/arm64'
69+ ${_GREEN} Default:${_CLEAR} 'linux/amd64'
70+
71+ BUILDX_BUILDER_NAME
72+ If defined, the image build will be assigned to the given builder.
73+ If you specify this variable, make sure that the builder exists.
74+ If this value is not defined, a new builx builder with the directory name of the
75+ current directory (i.e. '$( basename " ${PWD} " ) ') is created."
76+ ${_CYAN} Example:${_CLEAR} 'clever_lovelace'
77+ ${_GREEN} Default:${_CLEAR} undefined
78+
79+ BUILDX_REMOVE_BUILDER
80+ If defined (and only if BUILDX_BUILDER_NAME is undefined),
81+ then the buildx builder created by this script will be removed after use.
82+ This is useful if you build NetBox Docker on an automated system that does
83+ not manage the builders for you.
84+ ${_CYAN} Example:${_CLEAR} 'on'
85+ ${_GREEN} Default:${_CLEAR} undefined
86+
87+ HTTP_PROXY The proxy to use for http requests.
88+ ${_CYAN} Example:${_CLEAR} http://proxy.domain.tld:3128
89+ ${_GREEN} Default:${_CLEAR} undefined
90+
91+ NO_PROXY Comma-separated list of domain extensions proxy should not be used for.
92+ ${_CYAN} Example:${_CLEAR} .domain1.tld,.domain2.tld
93+ ${_GREEN} Default:${_CLEAR} undefined
94+
95+ DEBUG If defined, the script does not stop when certain checks are unsatisfied.
96+ ${_GREEN} Default:${_CLEAR} undefined
97+
98+ DRY_RUN Prints all build statements instead of running them.
99+ ${_GREEN} Default:${_CLEAR} undefined
100+
101+ GH_ACTION If defined, special 'echo' statements are enabled that set the
102+ following environment variables in Github Actions:
103+ - FINAL_DOCKER_TAG: The final value of the DOCKER_TAG env variable
104+ ${_GREEN} Default:${_CLEAR} undefined
105+
106+ ${_BOLD} Examples:${_CLEAR}
107+
108+ ${0} master
109+ This will fetch the latest 'master' branch, build a Docker Image and tag it
110+ 'netboxcommunity/netbox:latest'.
111+
112+ ${0} develop
113+ This will fetch the latest 'develop' branch, build a Docker Image and tag it
114+ 'netboxcommunity/netbox:snapshot'.
115+
116+ ${0} v2.6.6
117+ This will fetch the 'v2.6.6' tag, build a Docker Image and tag it
118+ 'netboxcommunity/netbox:v2.6.6' and 'netboxcommunity/netbox:v2.6'.
119+
120+ ${0} develop-2.7
121+ This will fetch the 'develop-2.7' branch, build a Docker Image and tag it
122+ 'netboxcommunity/netbox:develop-2.7'.
123+
124+ SRC_ORG=cimnine ${0} feature-x
125+ This will fetch the 'feature-x' branch from https://github.com/cimnine/netbox.git,
126+ build a Docker Image and tag it 'netboxcommunity/netbox:feature-x'.
127+
128+ SRC_ORG=cimnine DOCKER_ORG=cimnine ${0} feature-x
129+ This will fetch the 'feature-x' branch from https://github.com/cimnine/netbox.git,
130+ build a Docker Image and tag it 'cimnine/netbox:feature-x'.
131+ END_OF_HELP
99132
100133 if [ " ${1} x" == " x" ]; then
101134 exit 1
0 commit comments