Skip to content

Commit

Permalink
adding debug nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenaH84 committed Jun 15, 2024
1 parent 755bf3b commit 9115844
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
17 changes: 3 additions & 14 deletions docker-compose-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
version: "3.3"

services:

genie:
image: ghcr.io/battmoteam/battmogui_genie:latest
build: ./genie
container_name: genie
restart: always
ports:
- "8000:8000"
#command: gunicorn -w 1 -b 0.0.0.0:8000 wsgi:server --timeout 200
command: su genie -c 'julia --project=. -e "include("app/rest.jl")" --color=yes --depwarn=no --project=@. --sysimage="/home/sysimage.so" -q -i -- $$(dirname $$0)/../bootstrap.jl -s=true "$$@"'
command: su genie -c 'julia --project=. -e "include(\"app/rest.jl\")" --color=yes --depwarn=no --project=@. --sysimage=\"/home/sysimage.so\" -q -i -- $$(dirname $$0)/../bootstrap.jl -s=true "$$@"'

nginx:
image: ghcr.io/battmoteam/battmogui_nginx:latest
build: ./nginx
container_name: nginx
restart: always
ports:
Expand All @@ -24,19 +20,12 @@ services:
depends_on:
- genie
- streamlit
command: /bin/bash -c "/renew-certs.sh && nginx -g 'daemon off;'"
command: /renew-certs.sh

streamlit:
image: ghcr.io/battmoteam/battmogui_streamlit:latest
build: ./streamlit
container_name: streamlit
restart: always
ports:
- "80:80"
# volumes:
# - type: bind
# source: $HOST/location
# target: /container/location
# depends_on:
# - flask
command: streamlit run Introduction.py --global.disableWidgetStateDuplicationWarning true --server.port=80
1 change: 1 addition & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ COPY project.conf /etc/nginx/conf.d/
COPY renew-certs.sh /renew-certs.sh
RUN chmod +x /renew-certs.sh

# Entrypoint to handle certificate issuance and renewal
ENTRYPOINT ["/renew-certs.sh"]
35 changes: 31 additions & 4 deletions nginx/renew-certs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
#!/bin/bash
set -e

# Obtain/renew SSL certificates
certbot certonly --webroot -w /usr/share/nginx/html -d app.batterymodel.com --agree-tos --email [email protected]
# Reload Nginx to apply new certificates
nginx -s reload
# Function to start Nginx in the background
start_nginx() {
nginx -g 'daemon off;' &
NGINX_PID=$!
}

# Function to stop the Nginx process
stop_nginx() {
if [ -n "$NGINX_PID" ]; then
kill "$NGINX_PID"
fi
}

# Trap to ensure Nginx is stopped on script exit
trap stop_nginx EXIT

# Start Nginx to serve the challenge files
start_nginx

# Obtain or renew certificates
if [ ! -d "/etc/letsencrypt/live/app.batterymodel.com" ]; then
certbot certonly --webroot -w /usr/share/nginx/html -d app.batterymodel.com --email [email protected] --agree-tos --non-interactive
else
certbot renew --webroot -w /usr/share/nginx/html
fi

# Stop the background Nginx process
stop_nginx

# Start Nginx in the foreground
exec nginx -g 'daemon off;'

0 comments on commit 9115844

Please sign in to comment.