Skip to content

Home Information - Your home, your data, organized.

Python

Fixed: ngnix config issue, install link, Dockerfile improvements. (#148)

Tony Cff762ec18521
diff --git a/.github/workflows/release-assets.yml b/.github/workflows/release-assets.yml
new file mode 100644
index 00000000..d0a3bcb1
--- /dev/null
+++ b/.github/workflows/release-assets.yml
@@ -0,0 +1,29 @@
+name: Create Release Assets
+
+on:
+ release:
+ types: [published]
+
+jobs:
+ create-assets:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Create source archive using git archive
+ run: |
+ # Use git archive to create a clean zip that respects .gitignore
+ # Add version prefix so it unzips into a versioned directory
+ VERSION=${GITHUB_REF#refs/tags/}
+ git archive --format=zip --prefix=home-information-${VERSION}/ --output=home-information.zip HEAD
+
+ - name: Upload release asset
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ github.event.release.upload_url }}
+ asset_path: ./home-information.zip
+ asset_name: home-information.zip
+ asset_content_type: application/zip
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 8403d18e..9c973354 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,14 @@
-FROM python:3.11
+# Pin specific Python version for consistency across platforms
+FROM python:3.11.8-bookworm
+# Install dependencies with curl for healthcheck
RUN apt-get update \
- && apt-get install -y --no-install-recommends supervisor nginx redis-server redis-tools \
+ && apt-get install -y --no-install-recommends \
+ curl \
+ supervisor \
+ nginx \
+ redis-server \
+ redis-tools \
&& mkdir -p /var/log/supervisor \
&& mkdir -p /etc/supervisor/conf.d \
&& rm -rf /var/lib/apt/lists/* \
@@ -9,9 +16,9 @@ RUN apt-get update \
WORKDIR /src
-ENV PYTHONDONTWRITEBYTECODE 1
-ENV PYTHONUNBUFFERED 1
-ENV PYTHONPATH /src
+ENV PYTHONDONTWRITEBYTECODE=1
+ENV PYTHONUNBUFFERED=1
+ENV PYTHONPATH=/src
EXPOSE 8000
@@ -28,6 +35,12 @@ RUN pip install --no-cache-dir --root-user-action=ignore -r requirements.txt
COPY package/docker_supervisord.conf /etc/supervisor/conf.d/hi.conf
COPY package/docker_nginx.conf /etc/nginx/sites-available/default
+# Clean up nginx default configurations and ensure proper symlinks
+RUN rm -f /etc/nginx/conf.d/default.conf \
+ && rm -f /etc/nginx/sites-enabled/default \
+ && ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default \
+ && nginx -t
+
COPY package/docker_entrypoint.sh /src/entrypoint.sh
RUN chmod +x /src/entrypoint.sh
diff --git a/docs/Integrations.md b/docs/Integrations.md
index e8724c5e..261a4cb0 100644
--- a/docs/Integrations.md
+++ b/docs/Integrations.md
@@ -27,5 +27,5 @@ export HI_EXTRA_CSP_URLS="${SCHEME}://${HOST}:${PORT}"
### HTTPS/SSL Issues
-Another potential issue with viewing the ZoneMinder camera streams can happen if your Home Information server runs trhrough HTTP and the ZoneMinder server streams are served thruogh HTTPS/SSL. Browsers prevent that due the security implications. This can be made worse if the ZoneMinder server is using a self-signed SSL cert (the default?). A workaround we found was to stand up an nginx server to proxy the HTTPS/SSL urls and serve them as plain HTTP in Home Information pages by changing the ZoneMinder setting "Portal URL".
+Another potential issue with viewing the ZoneMinder camera streams can happen if your Home Information server runs trhrough HTTP and the ZoneMinder server streams are served thruogh HTTPS/SSL. Browsers prevent that due to the security implications. This can be made worse if the ZoneMinder server is using a self-signed SSL cert (the default?). A workaround we found was to stand up an nginx server to proxy the HTTPS/SSL urls and serve them as plain HTTP in Home Information pages by changing the ZoneMinder setting "Portal URL".
diff --git a/docs/dev/workflow/release-process.md b/docs/dev/workflow/release-process.md
index eea6f4ee..a905631f 100644
--- a/docs/dev/workflow/release-process.md
+++ b/docs/dev/workflow/release-process.md
@@ -66,10 +66,19 @@ Or via GitHub web interface:
7. **Settings**: Check "Set as latest release"
8. Click "Publish Release"
-## 5. Cleanup
+### 5. Validate Install URL Works
+
+Make sure that the published ZIP install link works and that it is at least 10MB in size.
+
+```bash
+curl -L https://github.com/cassandra/home-information/releases/latest/download/home-information.zip -o home-information.zip
+```
+
+## 6. Cleanup
For safety, move back to staging branch.
```bash
+git fetch --tags
git checkout staging
```
diff --git a/package/docker_nginx.conf b/package/docker_nginx.conf
index 4cb2dba0..9601b675 100644
--- a/package/docker_nginx.conf
+++ b/package/docker_nginx.conf
@@ -1,8 +1,3 @@
-server_tokens off;
-add_header X-XSS-Protection "1; mode=block";
-add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains;';
-add_header Permissions-Policy "geolocation=(self),autoplay=(self),camera=(),accelerometer=(),magnetometer=(self),ambient-light-sensor=(),gyroscope=(self),speaker=(self),vibrate=(self),fullscreen=(self),midi=(),encrypted-media=(),microphone=(),usb=(),picture-in-picture=(),vr=()";
-
upstream wsgi_server {
server unix:/var/run/gunicorn.sock fail_timeout=0;
}
@@ -12,33 +7,38 @@ server {
listen 0.0.0.0:8000;
listen [::]:8000;
server_name wsgi_server;
+
+ server_tokens off;
+ add_header X-XSS-Protection "1; mode=block";
+ add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains;';
+ add_header Permissions-Policy "geolocation=(self),autoplay=(self),camera=(),accelerometer=(),magnetometer=(self),ambient-light-sensor=(),gyroscope=(self),speaker=(self),vibrate=(self),fullscreen=(self),midi=(),encrypted-media=(),microphone=(),usb=(),picture-in-picture=(),vr=()";
client_max_body_size 20M;
location /favicon.ico {
alias /src/static/favicon.ico;
- access_log off;
- log_not_found off;
+ access_log off;
+ log_not_found off;
}
location /static/ {
- add_header Referrer-Policy "strict-origin";
- add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; connect-src 'self'; img-src 'self'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; manifest-src 'self'; font-src 'self'; style-src 'self' 'unsafe-inline' 'unsafe-eval';";
- add_header X-Content-Type-Options "nosniff";
+ add_header Referrer-Policy "strict-origin";
+ add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; connect-src 'self'; img-src 'self'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; manifest-src 'self'; font-src 'self'; style-src 'self' 'unsafe-inline' 'unsafe-eval';";
+ add_header X-Content-Type-Options "nosniff";
alias /src/static/;
- autoindex off;
+ autoindex off;
}
location /media/ {
- add_header Referrer-Policy "strict-origin";
- add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; connect-src 'self'; img-src 'self'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; manifest-src 'self'; font-src 'self'; style-src 'self' 'unsafe-inline' 'unsafe-eval';";
- add_header X-Content-Type-Options "nosniff";
+ add_header Referrer-Policy "strict-origin";
+ add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; connect-src 'self'; img-src 'self'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; manifest-src 'self'; font-src 'self'; style-src 'self' 'unsafe-inline' 'unsafe-eval';";
+ add_header X-Content-Type-Options "nosniff";
alias /data/media/;
- autoindex off;
+ autoindex off;
}
location / {
- index index.html;
+ index index.html;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;