Skip to content

Commit

Permalink
cleaner disabling of netbox by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed Sep 20, 2022
1 parent 58c21aa commit 7c0d37a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 20 deletions.
4 changes: 1 addition & 3 deletions Dockerfiles/netbox.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ ENV PUSER_PRIV_DROP true
ARG BASE_PATH=assets
ENV BASE_PATH $BASE_PATH

ARG NETBOX_DISABLED=false
ENV NETBOX_DISABLED $NETBOX_DISABLED

RUN apt-get -q update && \
apt-get -y -q --no-install-recommends upgrade && \
apt-get install -q -y --no-install-recommends \
Expand Down Expand Up @@ -55,6 +52,7 @@ COPY --chmod=755 shared/bin/docker-uid-gid-setup.sh /usr/local/bin/
COPY --chmod=755 shared/bin/service_check_passthrough.sh /usr/local/bin/
COPY --chmod=755 netbox/scripts/* /usr/local/bin/
COPY --chmod=644 netbox/supervisord.conf /etc/supervisord.conf
COPY --from=pierrezemb/gostatic --chmod=755 /goStatic /usr/bin/goStatic

ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-uid-gid-setup.sh", "/usr/local/bin/service_check_passthrough.sh"]

Expand Down
3 changes: 2 additions & 1 deletion Dockerfiles/opensearch.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ RUN yum install -y openssl util-linux procps && \

ADD shared/bin/docker-uid-gid-setup.sh /usr/local/bin/
ADD shared/bin/jdk-cacerts-auto-import.sh /usr/local/bin/
ADD shared/bin/service_check_passthrough.sh /usr/local/bin/docker-entrypoint.sh
COPY --chmod=755 shared/bin/service_check_passthrough.sh /usr/local/bin/docker-entrypoint.sh
COPY --from=pierrezemb/gostatic --chmod=755 /goStatic /usr/bin/goStatic

VOLUME ["/var/local/ca-trust"]

Expand Down
27 changes: 16 additions & 11 deletions Dockerfiles/postgresql.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,25 @@ ENV PUSER_CHOWN "/run/postgresql;/var/lib/postgresql"
ENV TERM xterm

COPY --chmod=755 shared/bin/docker-uid-gid-setup.sh /usr/local/bin/

RUN set -x && \
apk --no-cache add bash procps psmisc rsync shadow tini && \
rsync -a /usr/local/bin/ /usr/bin/ && \
rsync -a /usr/local/share/ /usr/share/ && \
rsync -a /usr/local/lib/ /usr/lib/ && \
rm -rf /usr/local/bin /usr/local/share /usr/local/lib && \
ln -s /usr/bin /usr/local/bin && \
ln -s /usr/share /usr/local/share && \
ln -s /usr/lib /usr/local/lib
COPY --chmod=755 shared/bin/service_check_passthrough.sh /usr/local/bin/
COPY --from=pierrezemb/gostatic --chmod=755 /goStatic /usr/bin/goStatic

RUN apk update --no-cache && \
apk upgrade --no-cache && \
apk add --no-cache bash procps psmisc shadow tini && \
apk add --no-cache --virtual .build-deps rsync && \
rsync -a /usr/local/bin/ /usr/bin/ && \
rsync -a /usr/local/share/ /usr/share/ && \
rsync -a /usr/local/lib/ /usr/lib/ && \
rm -rf /usr/local/bin /usr/local/share /usr/local/lib && \
ln -s /usr/bin /usr/local/bin && \
ln -s /usr/share /usr/local/share && \
ln -s /usr/lib /usr/local/lib && \
apk del .build-deps

USER root

ENTRYPOINT ["/sbin/tini", "--", "/usr/bin/docker-uid-gid-setup.sh"]
ENTRYPOINT ["/sbin/tini", "--", "/usr/bin/docker-uid-gid-setup.sh", "/usr/local/bin/service_check_passthrough.sh"]

CMD ["/usr/bin/docker-entrypoint.sh", "postgres"]

Expand Down
4 changes: 3 additions & 1 deletion Dockerfiles/redis.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ENV PUSER_PRIV_DROP true
ENV TERM xterm

COPY --chmod=755 shared/bin/docker-uid-gid-setup.sh /usr/local/bin/
COPY --chmod=755 shared/bin/service_check_passthrough.sh /usr/local/bin/
COPY --from=pierrezemb/gostatic --chmod=755 /goStatic /usr/bin/goStatic

RUN apk update --no-cache && \
apk upgrade --no-cache && \
Expand All @@ -29,7 +31,7 @@ RUN apk update --no-cache && \

WORKDIR /home/${PUSER}

ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/docker-uid-gid-setup.sh"]
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/docker-uid-gid-setup.sh", "/usr/local/bin/service_check_passthrough.sh"]

# to be populated at build-time:
ARG BUILD_DATE
Expand Down
5 changes: 4 additions & 1 deletion docker-compose-standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ x-filebeat-variables: &filebeat-variables
x-netbox-variables: &netbox-variables
# Parameters related to NetBox (and supporting tools). Note that other more specific parameters
# can also be configured in the env_file files for netbox* services
NETBOX_DISABLED : 'true'
NETBOX_DISABLED : &netboxdisabled 'true'
NETBOX_POSTGRES_DISABLED : *netboxdisabled
NETBOX_REDIS_DISABLED : *netboxdisabled
NETBOX_REDIS_CACHE_DISABLED : *netboxdisabled

x-common-upload-variables: &common-upload-variables
# Whether or not to automatically apply tags based (on the PCAP filename) to network traffic metadata
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ x-filebeat-variables: &filebeat-variables
x-netbox-variables: &netbox-variables
# Parameters related to NetBox (and supporting tools). Note that other more specific parameters
# can also be configured in the env_file files for netbox* services
NETBOX_DISABLED : 'true'
NETBOX_DISABLED : &netboxdisabled 'true'
NETBOX_POSTGRES_DISABLED : *netboxdisabled
NETBOX_REDIS_DISABLED : *netboxdisabled
NETBOX_REDIS_CACHE_DISABLED : *netboxdisabled

x-common-upload-variables: &common-upload-variables
# Whether or not to automatically apply tags based (on the PCAP filename) to network traffic metadata
Expand Down
7 changes: 5 additions & 2 deletions shared/bin/service_check_passthrough.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ while getopts 'vds:p:f:' OPTION; do
case "$OPTION" in
v)
VERBOSE_FLAG="-v"
set -x
;;

d)
Expand Down Expand Up @@ -71,7 +72,7 @@ if [[ -z "$SERVICE" ]]; then
SERVICE="$(uname -a | awk '{print $2}')"
fi
fi
SERVICE_UCASE="$(echo ${SERVICE^^})"
SERVICE_UCASE="$(echo ${SERVICE^^} | tr '-' '_')"

# if disabled wasn't specified, but service was, check environment variables
if [[ -z "$DISABLED" ]] && [[ -n "$SERVICE" ]]; then
Expand Down Expand Up @@ -154,7 +155,9 @@ EOF
EOF
fi # json vs http

if command -v python3 >/dev/null 2>&1; then
if command -v goStatic >/dev/null 2>&1; then
goStatic -path "$(pwd)" -fallback "index.html" -port $PORT
elif command -v python3 >/dev/null 2>&1; then
python3 -m http.server --bind 0.0.0.0 $PORT
elif command -v python >/dev/null 2>&1; then
python -m SimpleHTTPServer $PORT
Expand Down

0 comments on commit 7c0d37a

Please sign in to comment.