aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Dockerfile2
-rw-r--r--app.py5
-rwxr-xr-xdeploy.sh14
3 files changed, 21 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
index 0a27cb9..3b11c37 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,4 +7,6 @@ COPY templates /app/templates
COPY app.py pyproject.toml .python-version uv.lock /app/
RUN uv sync
+EXPOSE 8000
+
CMD ["uv", "run", "gunicorn", "--bind", "0.0.0.0:8000", "app:app", "-w", "1"]
diff --git a/app.py b/app.py
index fe67838..bee1188 100644
--- a/app.py
+++ b/app.py
@@ -67,6 +67,11 @@ def download_and_create_thumbnail(file_id):
response = requests.get(url)
response.raise_for_status()
img = Image.open(BytesIO(response.content))
+
+ # Convert to RGB if image has alpha channel (RGBA or P)
+ if img.mode in ("RGBA", "P"):
+ img = img.convert("RGB")
+
img.thumbnail((400, 400))
path = os.path.join(THUMBNAIL_DIR, f"{file_id}.jpg")
img.save(path, format="JPEG")
diff --git a/deploy.sh b/deploy.sh
new file mode 100755
index 0000000..fa385f4
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# Use e.g. `direnv` to set the deploy variables
+
+set -euxo pipefail
+
+IMAGE=${OCI_REGISTRY}/gdrive-photo-gallery:latest
+
+# Build
+docker build --progress plain --platform linux/amd64 -t "$IMAGE" .
+docker push "$IMAGE"
+
+# Deploy
+ssh "${SSH_SERVER}" "${UPDATE_COMMAND}"