Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

feat: add sh entrypoint to allow MEMOS_DSN_FILE to load variable from secret (#4236)

Hadley Rich82b5c8ab0795
diff --git a/Dockerfile b/Dockerfile
index af35f19a5..8ebee92da 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -27,6 +27,7 @@ RUN apk add --no-cache tzdata
ENV TZ="UTC"
COPY --from=backend /backend-build/memos /usr/local/memos/
+COPY entrypoint.sh /usr/local/memos/
EXPOSE 5230
@@ -37,4 +38,4 @@ VOLUME /var/opt/memos
ENV MEMOS_MODE="prod"
ENV MEMOS_PORT="5230"
-ENTRYPOINT ["./memos"]
+ENTRYPOINT ["./entrypoint.sh", "./memos"]
diff --git a/entrypoint.sh b/entrypoint.sh
new file mode 100755
index 000000000..a73f40136
--- /dev/null
+++ b/entrypoint.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env sh
+
+file_env() {
+ var="$1"
+ fileVar="${var}_FILE"
+
+ val_var="$(printenv "$var")"
+ val_fileVar="$(printenv "$fileVar")"
+
+ if [ -n "$val_var" ] && [ -n "$val_fileVar" ]; then
+ echo "error: both $var and $fileVar are set (but are exclusive)" >&2
+ exit 1
+ fi
+
+ if [ -n "$val_var" ]; then
+ val="$val_var"
+ elif [ -n "$val_fileVar" ]; then
+ val="$(cat "$val_fileVar")"
+ fi
+
+ export "$var"="$val"
+ unset "$fileVar"
+}
+
+file_env "MEMOS_DSN"
+
+exec "$@"