Skip to content

Commit

Permalink
Merge branch '361-improve-installation-script' into 'main'
Browse files Browse the repository at this point in the history
Resolve "Improve installation script"

Closes #361

See merge request reportcreator/reportcreator!621
  • Loading branch information
MWedl committed Jul 31, 2024
2 parents 4865130 + a9f2f6d commit 238f143
Show file tree
Hide file tree
Showing 18 changed files with 432 additions and 286 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Next
* Rework install.sh
* Set restart policy for redis docker container
* Add setting to disable websockets and always use HTTP for collaborative editing
* Fix error while sorting finding templates by created/updated date
Expand Down
17 changes: 17 additions & 0 deletions deploy/caddy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Do not modify. This file is automatically generated.
# Changes will be overwritten.
services:
caddy:
image: caddy:latest
container_name: 'sysreptor-caddy'
restart: unless-stopped
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- type: volume
source: sysreptor-caddy-data
target: /data
network_mode: "host"

volumes:
sysreptor-caddy-data:
name: sysreptor-caddy-data
85 changes: 85 additions & 0 deletions deploy/caddy/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash
cd `dirname "$BASH_SOURCE"`
if
test -f Caddyfile
then
echo "Caddyfile exists. Skipping web server setup."
read -p "Press any key to continue installation..."
echo ""
cd - >/dev/null
return 2>/dev/null || exit -1 # return if script is source, exit if in process
fi
while [[ "$SYSREPTOR_WEBSERVER" != [yY] && "$SYSREPTOR_WEBSERVER" != [nN] ]]
do
echo ""
echo "SysReptor runs on localhost (127.0.0.1) by default."
read -p "Should we setup a webserver (Caddy in Docker) for you to expose it to your local network or the Internet? [y/n]: " SYSREPTOR_WEBSERVER
if [[ "$SYSREPTOR_WEBSERVER" == [yY] ]]
then
while [[ "$SYSREPTOR_LETSENCRYPT" != [yY] && "$SYSREPTOR_LETSENCRYPT" != [nN] ]]
do
echo ""
echo "Should we take care of your webserver HTTPS certificate using LetsEncrypt?"
echo "For this, you must set up:"
echo " 1. a valid domain name resolving to your public IP address"
echo " 2. port 80 of your must be publicly reachable"
read -p "Want a LetsEncrypt webserver certificate? [y/n]: " SYSREPTOR_LETSENCRYPT
done
while ! case "$SYSREPTOR_CADDY_PORT" in ''|*[!0-9]*) false;;esac;
do
if [[ "$SYSREPTOR_LETSENCRYPT" == [yY] ]]
then
default_port=443
else
default_port=80
fi
read -p "What port should the webserver use? [$default_port] " SYSREPTOR_CADDY_PORT
SYSREPTOR_CADDY_PORT=${SYSREPTOR_CADDY_PORT:-$default_port}
if [[ "$SYSREPTOR_CADDY_PORT" -lt 1 || "$SYSREPTOR_CADDY_PORT" -gt 65535 ]]
then
echo "Invalid port number. Please enter a valid port number between 1 and 65535."
SYSREPTOR_CADDY_PORT=""
elif [[ "$SYSREPTOR_CADDY_PORT" -eq 8000 ]]
then
echo "The Django app uses port 8000 on 127.0.0.1. Please use a different port."
SYSREPTOR_CADDY_PORT=""
fi
done
if [[ "$SYSREPTOR_LETSENCRYPT" == [yY] ]]
then
while [ -z "$SYSREPTOR_CADDY_FQDN" ]
do
read -p "What is your publicly reachable fully qualified domain name (e.g., sysreptor.example.com)? " SYSREPTOR_CADDY_FQDN
done
fi
fi
done
if [[ "$SYSREPTOR_WEBSERVER" == [nN] ]]
then
echo "Okay. Won't set up a webserver."
else
# Create config
echo """# Do not modify. This file is automatically generated.
# Changes will be overwritten.
$SYSREPTOR_CADDY_FQDN:$SYSREPTOR_CADDY_PORT
reverse_proxy http://127.0.0.1:8000""" > Caddyfile
echo "Setting up your web server..."

docker_compose_file="../docker-compose.yml"
include_caddy=" - caddy/docker-compose.yml"
if ! grep -q "^$include_caddy" "$docker_compose_file"
then
# Include Caddy in docker-compose.yml
sed -i "s#include:#include:\n$include_caddy#" "$docker_compose_file"
fi
fi
docker container stop sysreptor-caddy 1>/dev/null 2>&1 && docker container rm sysreptor-caddy 1>/dev/null 2>&1 || true
echo ""
cd - >/dev/null
return 2>/dev/null || true # return if script is source

cd `dirname "$BASH_SOURCE"`
cd ..
docker compose up -d
cd - >/dev/null
40 changes: 5 additions & 35 deletions deploy/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
name: sysreptor

services:
app:
environment:
SPELLCHECK_URL: http://languagetool:8010/
depends_on:
languagetool:
condition: service_started
languagetool:
build:
context: ../languagetool
args:
CA_CERTIFICATES: ${SYSREPTOR_CA_CERTIFICATES-}
container_name: 'sysreptor-languagetool'
init: true
environment:
languagetool_dbHost: db
languagetool_dbName: reportcreator
languagetool_dbUsername: reportcreator
languagetool_dbPassword: reportcreator
HTTP_PROXY: ${HTTP_PROXY-}
HTTPS_PROXY: ${HTTPS_PROXY-}
expose:
- 8010
healthcheck:
test: ["CMD", "curl", "-f", "-so", "/dev/null", "http://localhost:8010/v2/languages"]
interval: 30s
timeout: 30s
retries: 5
start_period: 10s
restart: unless-stopped
depends_on:
db:
condition: service_healthy
# This file is included due to legacy reasons
# It makes sure that Docker starts the languagetool container for Pro customers
# We will delete this file in July 2025
include:
- languagetool/docker-compose.yml
80 changes: 2 additions & 78 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,4 @@
# Do not modify. This file is automatically generated.
# Changes will be overwritten.
name: sysreptor

services:
db:
image: 'postgres:14'
container_name: 'sysreptor-db'
environment:
POSTGRES_USER: reportcreator
POSTGRES_PASSWORD: reportcreator
POSTGRES_DB: reportcreator
PGDATA: /data
volumes:
- type: volume
source: db-data
target: /data
expose:
- 5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U reportcreator"]
interval: 2s
timeout: 5s
retries: 30
restart: unless-stopped
stop_grace_period: 120s
redis:
image: bitnami/redis:7.2
environment:
REDIS_PASSWORD: reportcreator
expose:
- 6379
restart: unless-stopped
app:
build:
context: ../
target: api
args:
VERSION: ${SYSREPTOR_VERSION}
CA_CERTIFICATES: ${SYSREPTOR_CA_CERTIFICATES-}
container_name: 'sysreptor-app'
init: true
volumes:
- type: volume
source: app-data
target: /data
expose:
- 8000
ports:
- ${BIND_PORT:-127.0.0.1:8000:8000}
environment:
DATABASE_HOST: db
DATABASE_NAME: reportcreator
DATABASE_USER: reportcreator
DATABASE_PASSWORD: reportcreator
REDIS_URL: redis://:reportcreator@redis:6379/0
HTTP_PROXY: ${HTTP_PROXY-}
HTTPS_PROXY: ${HTTPS_PROXY-}
env_file: app.env
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/utils/healthcheck/"]
interval: 30s
timeout: 30s
retries: 5
start_period: 10s
depends_on:
db:
condition: service_healthy
redis:
condition: service_started


volumes:
db-data:
name: sysreptor-db-data
external: true
app-data:
name: sysreptor-app-data
external: true
include:
- sysreptor/docker-compose.yml
29 changes: 29 additions & 0 deletions deploy/languagetool/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Do not modify. This file is automatically generated.
# Changes will be overwritten.
services:
languagetool:
build:
context: ../../languagetool
args:
CA_CERTIFICATES: ${SYSREPTOR_CA_CERTIFICATES-}
container_name: 'sysreptor-languagetool'
init: true
environment:
languagetool_dbHost: db
languagetool_dbName: reportcreator
languagetool_dbUsername: reportcreator
languagetool_dbPassword: reportcreator
HTTP_PROXY: ${HTTP_PROXY-}
HTTPS_PROXY: ${HTTPS_PROXY-}
expose:
- 8010
healthcheck:
test: ["CMD", "curl", "-f", "-so", "/dev/null", "http://localhost:8010/v2/languages"]
interval: 30s
timeout: 30s
retries: 5
start_period: 10s
restart: unless-stopped
depends_on:
db:
condition: service_healthy
4 changes: 2 additions & 2 deletions deploy/sysreptor.nginx → deploy/nginx/sysreptor.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ server {
ssl_stapling on;
ssl_stapling_verify on;

# Timeouts for long running websocket connections and long PDF rendering tasks
# Timeouts for long running websocket connections and long PDF rendering tasks
proxy_read_timeout 5m;
proxy_send_timeout 5m;
client_max_body_size 0;
Expand All @@ -35,6 +35,6 @@ server {

# Websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Connection "Upgrade";
}
}
80 changes: 80 additions & 0 deletions deploy/sysreptor/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Do not modify. This file is automatically generated.
# Changes will be overwritten.
name: sysreptor

services:
db:
image: 'postgres:14'
container_name: 'sysreptor-db'
environment:
POSTGRES_USER: reportcreator
POSTGRES_PASSWORD: reportcreator
POSTGRES_DB: reportcreator
PGDATA: /data
volumes:
- type: volume
source: db-data
target: /data
expose:
- 5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U reportcreator"]
interval: 2s
timeout: 5s
retries: 30
restart: unless-stopped
stop_grace_period: 120s
redis:
image: bitnami/redis:7.2
container_name: 'sysreptor-redis'
environment:
REDIS_PASSWORD: reportcreator
expose:
- 6379
restart: unless-stopped
app:
build:
context: ../..
target: api
args:
VERSION: ${SYSREPTOR_VERSION}
CA_CERTIFICATES: ${SYSREPTOR_CA_CERTIFICATES-}
SPELLCHECK_URL: ${SYSREPTOR_SPELLCHECK_URL:-http://languagetool:8010/}
container_name: 'sysreptor-app'
init: true
volumes:
- type: volume
source: app-data
target: /data
expose:
- 8000
ports:
- ${BIND_PORT:-127.0.0.1:8000:8000}
environment:
DATABASE_HOST: db
DATABASE_NAME: reportcreator
DATABASE_USER: reportcreator
DATABASE_PASSWORD: reportcreator
REDIS_URL: redis://:reportcreator@redis:6379/0
HTTP_PROXY: ${HTTP_PROXY-}
HTTPS_PROXY: ${HTTPS_PROXY-}
env_file: ../app.env
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/utils/healthcheck/"]
interval: 30s
timeout: 30s
retries: 5
start_period: 10s
depends_on:
db:
condition: service_healthy


volumes:
db-data:
name: sysreptor-db-data
external: true
app-data:
name: sysreptor-app-data
external: true
2 changes: 1 addition & 1 deletion docs/docs/finding-templates/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ You can hide these fields in the template editor to focus on the relevant fields

Markdown fields allow pasting images from your clipboard:

![Paste image to markdown field](../images/show/images_in_templates.gif)
![Paste image to markdown field](../images/show/images_in_templates.gif)
Loading

0 comments on commit 238f143

Please sign in to comment.