Skip to content

Commit

Permalink
Run as Deployment
Browse files Browse the repository at this point in the history
Closes #13
  • Loading branch information
edwardtheharris committed Aug 13, 2024
1 parent 8d0cc7e commit 5d5f6a6
Show file tree
Hide file tree
Showing 18 changed files with 728 additions and 174 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.md
7 changes: 4 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ def get_release():

exclude_patterns = [
'_build',
'Thumbs.db',
'.DS_Store',
'.venv/*',
'.tmp/*',
'.gnupg/*',
'.pytest_cache/*',
'.tmp/*',
'.venv/*',
'Thumbs.db',
]

extensions = [
Expand Down
8 changes: 6 additions & 2 deletions config/celery.init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -x

cat /opt/.celery/resolv.conf > /etc/resolv.conf

rm -rfv /opt/celery

mkdir -pv /opt/celery
Expand All @@ -12,9 +14,9 @@ apk add --no-cache sudo

sudo -u celery python -m venv /opt/celery

sudo -u celery /opt/celery/bin/pip install -U pip
sudo -u celery /opt/celery/bin/pip install --no-cache-dir -U pip -v

sudo -u celery /opt/celery/bin/pip install -r /opt/.celery/reqs
sudo -u celery /opt/celery/bin/pip install --no-cache-dir -r /opt/.celery/reqs

cat /opt/.celery/.bashrc > /opt/celery/.bashrc

Expand All @@ -24,3 +26,5 @@ NAUTOBOT_ROOT=/opt/celery
export NAUTOBOT_ROOT

sudo -E -u celery /opt/celery/bin/nautobot-server init

exit 0
15 changes: 10 additions & 5 deletions config/nautobot.init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@

set -x

rm -rfv /opt/nautobot
cat /opt/.nautobot/resolv.conf > /etc/resolv.conf

apk add --no-cache sudo

rm -rf /opt/nautobot/*

mkdir -pv /opt/nautobot

chown -v nautobot:nautobot /opt/nautobot

apk add --no-cache sudo

sudo -u nautobot python -m venv /opt/nautobot

sudo -u nautobot /opt/nautobot/bin/pip install -U pip
sudo -u nautobot /opt/nautobot/bin/pip install --no-cache-dir -U pip

sudo -u nautobot /opt/nautobot/bin/pip install -r /opt/.nautobot/reqs
sudo -u nautobot /opt/nautobot/bin/pip install --no-cache-dir -r /opt/.nautobot/reqs

cat /opt/.nautobot/.bashrc > /opt/nautobot/.bashrc

chown -v nautobot:nautobot /opt/nautobot/.bashrc

NAUTOBOT_ROOT=/opt/nautobot

export NAUTOBOT_ROOT

sudo -E -u nautobot /opt/nautobot/bin/nautobot-server init
Expand All @@ -30,3 +33,5 @@ sudo -E -u nautobot /opt/nautobot/bin/nautobot-server migrate
sudo -E -u nautobot /opt/nautobot/bin/nautobot-server createsuperuser --email "${NAUTOBOT_SUPERUSER_EMAIL}" --username "${NAUTOBOT_SUPERUSER_USERNAME}" --noinput

sudo -E -u nautobot /opt/nautobot/bin/nautobot-server collectstatic

exit 0
2 changes: 0 additions & 2 deletions config/reqs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
gitpython
celery[redis]
loguru
lxml
nautobot[sso]
redis
wheel
xmlsec
4 changes: 4 additions & 0 deletions config/resolv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
search nautobot.svc.cluster.local postgresql.svc.cluster.local svc.cluster.local cluster.local socal.rr.com
nameserver 8.8.8.8
nameserver 10.96.0.10
options ndots:5
11 changes: 5 additions & 6 deletions container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM python:3.11-alpine AS build
ARG PYTHON_VERSION='3.12'
FROM python:${PYTHON_VERSION}-alpine AS build
ARG VERSION
ARG USER=nautobot
LABEL io.ghcr.edwardtheharris.helm-nautobot.editor="Xander Harris"
LABEL io.ghcr.edwardtheharris.helm-nautobot.name="${USER}"
LABEL org.opencontainers.image.source="https://github.com/edwardtheharris/helm-nautobot"
LABEL io.ghcr.edwardtheharris.helm-nautobot.version="0.0.1.rc30"
COPY container/${USER}.entrypoint.sh /bin/entrypoint.sh
COPY container/reqs /opt/${USER}/reqs
LABEL io.ghcr.edwardtheharris.helm-nautobot.version="${VERSION}"
RUN apk add --no-cache \
alpine-sdk \
bash \
Expand All @@ -21,7 +21,6 @@ RUN apk add --no-cache \
vim \
xmlsec-dev \
zlib-dev \
&& chmod +x /bin/entrypoint.sh \
&& groupadd ${USER} \
&& useradd -s /bin/bash -m -d /opt/${USER} -g ${USER} ${USER}
CMD ["/bin/entrypoint.sh", "${USER}"]
CMD ["tail", "-f", "/dev/null"]
10 changes: 0 additions & 10 deletions container/celery.entrypoint.sh

This file was deleted.

11 changes: 9 additions & 2 deletions container/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ To build the nautobot container you run the build command below.
VERSION=0.0.1
docker build -t ghcr.io/edwardtheharris/helm-nautobot/nautobot:${VERSION} \
export VERSION
docker build --build-arg VERSION="${VERSION}" \
--build-arg PYTHON_VERSION='3.12' \
-t ghcr.io/edwardtheharris/helm-nautobot/nautobot:${VERSION} \
--progress plain --push -f container/Dockerfile .
```

Expand All @@ -29,7 +33,10 @@ argument as shown below.
VERSION=0.0.1
docker build --build-arg USER=celery \
export VERSION
docker build --build-arg PYTHON_VERSION='3.12' --build-arg USER=celery \
--build-arg="${VERSION}" \
-t ghcr.io/edwardtheharris/helm-nautobot/celery:${VERSION} \
--progress plain --push -f container/Dockerfile .
```
7 changes: 0 additions & 7 deletions container/nautobot.entrypoint.sh

This file was deleted.

2 changes: 0 additions & 2 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Common labels
helm.sh/chart: {{ include "nautobot.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
app.kubernetes.io/component: backend
app.kubernetes.io/part-of: nautobot
{{ include "nautobot.selectorLabels" . }}
{{- if .Chart.AppVersion }}
Expand All @@ -50,7 +49,6 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
Selector labels
*/}}
{{- define "nautobot.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nautobot.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

Expand Down
6 changes: 6 additions & 0 deletions templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ data:
uwsgi.ini: |-
{{- $.Files.Get "config/uwsgi.ini" | nindent 4 }}
resolv.conf: |-
{{- $.Files.Get "config/resolv.conf" | nindent 4 }}
reqs: |-
{{- $.Files.Get "config/reqs" | nindent 4 }}
Expand All @@ -33,5 +36,8 @@ data:
reqs: |-
{{- $.Files.Get "config/reqs" | nindent 4 }}
resolv.conf: |-
{{- $.Files.Get "config/resolv.conf" | nindent 4 }}
init.sh: |-
{{- $.Files.Get "config/celery.init.sh" | nindent 4 }}
Loading

0 comments on commit 5d5f6a6

Please sign in to comment.