mirror of
https://github.com/eduardogsilva/routerfleet.git
synced 2025-07-22 20:04:51 +02:00
Docker compose and startup adjustments
This commit is contained in:
parent
563ee7408e
commit
a194e4f0be
8 changed files with 56 additions and 8 deletions
|
@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y \
|
|||
nano \
|
||||
vim-nox \
|
||||
fping \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
|
|
@ -93,6 +93,9 @@ def update_and_monitor():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"{datetime.now()} - Monitoring container started, waiting for routerfleet container to start...")
|
||||
time.sleep(30) # Wait for the routerfleet container to start
|
||||
print(f"{datetime.now()} - Starting monitoring service...")
|
||||
update_and_monitor()
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
version: '3'
|
||||
services:
|
||||
routerfleet-postgres:
|
||||
container_name: routerfleet-postgres
|
||||
image: postgres:latest
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_DB=routerfleet
|
||||
- POSTGRES_USER=routerfleet
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
|
||||
routerfleet:
|
||||
container_name: routerfleet
|
||||
restart: unless-stopped
|
||||
|
@ -8,10 +17,14 @@ services:
|
|||
environment:
|
||||
- SERVER_ADDRESS=${SERVER_ADDRESS}
|
||||
- DEBUG_MODE=${DEBUG_MODE}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
|
||||
volumes:
|
||||
- media_root:/var/lib/routerfleet/
|
||||
- static_volume:/app_static_files/
|
||||
command: /bin/bash /app/init.sh
|
||||
depends_on:
|
||||
- routerfleet-postgres
|
||||
|
||||
routerfleet-cron:
|
||||
container_name: routerfleet-cron
|
||||
|
@ -22,13 +35,22 @@ services:
|
|||
depends_on:
|
||||
- routerfleet
|
||||
|
||||
routerfleet-monitoring:
|
||||
container_name: routerfleet-monitoring
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: ./containers/monitoring
|
||||
dockerfile: Dockerfile-monitoring
|
||||
depends_on:
|
||||
- routerfleet
|
||||
|
||||
nginx:
|
||||
container_name: routerfleet-nginx
|
||||
restart: unless-stopped
|
||||
image: nginx:alpine
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile_nginx
|
||||
context: ./containers/nginx
|
||||
dockerfile: Dockerfile-nginx
|
||||
volumes:
|
||||
- ./containers/nginx/virtualhost.conf:/etc/nginx/conf.d/routerfleet.conf
|
||||
- static_volume:/static
|
||||
|
@ -36,8 +58,11 @@ services:
|
|||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
depends_on:
|
||||
- routerfleet
|
||||
|
||||
volumes:
|
||||
static_volume:
|
||||
https_cert:
|
||||
media_root:
|
||||
postgres_data:
|
||||
|
|
|
@ -7,6 +7,11 @@ if [ -z "$SERVER_ADDRESS" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$POSTGRES_PASSWORD" ]; then
|
||||
echo "POSTGRES_PASSWORD environment variable is not set. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEBUG_VALUE="False"
|
||||
if [[ "${DEBUG_MODE,,}" == "true" ]]; then
|
||||
DEBUG_VALUE="True"
|
||||
|
@ -17,8 +22,18 @@ DEBUG = $DEBUG_VALUE
|
|||
ALLOWED_HOSTS = ['routerfleet', '$SERVER_ADDRESS']
|
||||
CSRF_TRUSTED_ORIGINS = ['http://routerfleet', 'https://$SERVER_ADDRESS']
|
||||
SECRET_KEY = '$(openssl rand -base64 32)'
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'routerfleet',
|
||||
'USER': 'routerfleet',
|
||||
'PASSWORD': '$POSTGRES_PASSWORD',
|
||||
'HOST': 'routerfleet-postgres',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
EOL
|
||||
|
||||
#sed -i "/^ path('admin\/', admin.site.urls),/s/^ / # /" /app/routerfleet/urls.py
|
||||
sed -i "/^ path('admin\/', admin.site.urls),/s/^ / # /" /app/routerfleet/urls.py
|
||||
|
||||
exec "$@"
|
|
@ -11,6 +11,7 @@ django-cleanup==8.1.0
|
|||
django-crispy-forms==2.1
|
||||
idna==3.6
|
||||
paramiko==3.4.0
|
||||
psycopg2-binary==2.9.9
|
||||
pycparser==2.21
|
||||
PyNaCl==1.5.0
|
||||
requests==2.31.0
|
||||
|
|
|
@ -64,7 +64,7 @@ def view_manage_router(request):
|
|||
form = RouterForm(request.POST or None, instance=router)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, 'Router saved successfully')
|
||||
messages.success(request, 'Router saved successfully|It may take a few minutes until monitoring starts for this router.')
|
||||
router_status, _ = RouterStatus.objects.get_or_create(router=form.instance)
|
||||
BackupSchedule.objects.filter(router=form.instance).delete()
|
||||
return redirect('router_list')
|
||||
|
|
|
@ -40,13 +40,17 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<a href="/router/manage_sshkey/" class="btn btn-primary">Add SSH Key</a>
|
||||
{% comment %}<a href="/router/manage_sshkey/" class="btn btn-primary">Add SSH Key</a>{% endcomment %}
|
||||
<a href="" class="btn btn-primary disabled">Add SSH Key</a>
|
||||
<p>Sorry, SSH authentication using keys is still unsupported. It will be added soon</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue