Skip to content

Commit

Permalink
add Memos addon (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-garavini authored Jan 31, 2025
2 parents 130e864 + 740c485 commit ce28539
Show file tree
Hide file tree
Showing 25 changed files with 591 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ A self-hostable bookmark-everything app with a touch of AI for the data hoarders

[Jellyfin](https://jellyfin.org) is a Free Software Media System that puts you in control of managing and streaming your media.

### Memos 🦜

*All-in-one*

An open-source, self-hosted note-taking solution designed for seamless deployment and multi-platform access. Experience effortless plain text writing with pain-free, complemented by robust Markdown syntax support for enhanced formatting.

### Nextcloud ☁️

*All-in-one*
Expand Down
1 change: 1 addition & 0 deletions memos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 0.21.0
19 changes: 19 additions & 0 deletions memos/DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Home Assistant add-on: Memos 🦜 by Fabio Garavini

An open-source, self-hosted note-taking solution designed for seamless deployment and multi-platform access. Experience effortless plain text writing with pain-free, complemented by robust Markdown syntax support for enhanced formatting.

## Installation

To install the Memos Addon, follow these steps:

1. Open the Home Assistant UI and navigate to the Add-ons page
1. Click the "Memos" addon
1. Click the "Install" button
1. Click the "Open Web UI" button
1. Create a new user

## Ports

The Hoarder Addon exposes the following ports:

- `5230/tcp`: The web UI port
55 changes: 55 additions & 0 deletions memos/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ARG BUILD_FROM

FROM ${BUILD_FROM}

ARG BUILD_ARCH

ENV MEMOS_MODE="prod" \
MEMOS_PORT="5230" \
MEMOS_DATA="/share/memos" \
MEMOS_DRIVER="postgres" \
PGDATA="/config/postgres" \
MEMOS_DSN="user=memos password=memos dbname=memos host=127.0.0.1 sslmode=disable" \
POSTGRES_USER="memos" \
POSTGRES_PASSWORD="memos" \
POSTGRES_DB="memos" \
PG_MAJOR=16

RUN apk add --no-cache bash logrotate postgresql$PG_MAJOR postgresql$PG_MAJOR-client; \
# groupadd -r -g 900 postgres; \
# useradd -r -u 900 -g postgres --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql; \
install --verbose --directory --owner postgres --group postgres --mode 3777 /var/run/postgresql

COPY --from=neosmemo/memos:0.23.1 /usr/local/memos/memos /usr/local/memos/

COPY rootfs/ /

VOLUME /config /data /share

EXPOSE ${MEMOS_PORT}

ARG BUILD_VERSION
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
LABEL \
io.hass.name="${BUILD_NAME}" \
io.hass.description="${BUILD_DESCRIPTION}" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version="${BUILD_VERSION}" \
maintainer="Fabio Garavini <[email protected]>" \
org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.vendor="Fabio Garavini Hassio Add-ons" \
org.opencontainers.image.authors="Fabio Garavini <[email protected]>" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://github.com/fabio-garavini" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}
14 changes: 14 additions & 0 deletions memos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Home Assistant add-on: Memos 🦜 by Fabio Garavini

An open-source, self-hosted note-taking solution designed for seamless deployment and multi-platform access. Experience effortless plain text writing with pain-free, complemented by robust Markdown syntax support for enhanced formatting.

![screenshot](https://camo.githubusercontent.com/e31052e97a940bf0afde9a63e59dd7a03c7cb698e0378df0876d131972b115a9/68747470733a2f2f7777772e7573656d656d6f732e636f6d2f64656d6f2e706e67)

## Main Features

- Privacy First 🏠: Take control of your data. All runtime data is securely stored in your local database.
- Create at Speed ✍️: Save content as plain text for quick access, with Markdown support for fast formatting and easy sharing.
- Lightweight but Powerful 🤲: Built with Go, React.js, and a compact architecture, our application delivers powerful performance in a lightweight package.
- Customizable 🧩: Easily customize your server name, icon, description, system style, and execution scripts to make it uniquely yours.
- Open Source 🦦: Memos embraces the future of open source, with all code available on GitHub for transparency and collaboration.
- Free to Use 💸: Enjoy all features completely free, with no charges ever for any content.
67 changes: 67 additions & 0 deletions memos/apparmor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <tunables/global>

profile memos flags=(attach_disconnected,mediate_deleted) {
#include <abstractions/base>

capability,
file,
signal,
mount,
umount,
remount,
network udp,
network tcp,
network dgram,
network stream,
network inet,
network inet6,
network netlink raw,
network unix dgram,

capability setgid,
capability setuid,
capability sys_admin,
capability dac_read_search,
# capability dac_override,
# capability sys_rawio,

# S6-Overlay
/init ix,
/bin/** ix,
/usr/bin/** ix,
/usr/local/bin/** ix,
/run/{s6,s6-rc*,service}/** ix,
/package/** ix,
/command/** ix,
/etc/s6/** rix,
/run/s6/** rix,
/etc/services.d/** rwix,
/etc/cont-init.d/** rwix,
/etc/cont-finish.d/** rwix,
/var/run/{,**} mrwkl,
/run/{,**} rwk,
/dev/tty rw,

/dev/** mrwkl,

# Bashio
/usr/lib/bashio/** ix,
/tmp/** mrwkl,

/usr/share/zoneinfo/** rw,
/etc/localtime rw,
/etc/environment rw,

/usr/lib/postgresql/** rwix,
/etc/postgresql/** rwix,
/usr/share/postgresql/** rwix,

# Data access
/data/** rw,
/config/** rw,
/share/** rw,
/media/** rw,
/ssl/** r,

/usr/local/memos/{,**} rwix,
}
6 changes: 6 additions & 0 deletions memos/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build_from:
aarch64: ghcr.io/hassio-addons/base:stable
amd64: ghcr.io/hassio-addons/base:stable
codenotary:
signer: [email protected]
base_image: [email protected]
26 changes: 26 additions & 0 deletions memos/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Memos
version: "0.23.1-v0"
slug: memos
codenotary: [email protected]
description: note-taking solution designed for seamless deployment and multi-platform access
url: https://www.usememos.com/
webui: http://[HOST]:[PORT:5230]
arch:
- aarch64
- amd64
init: false
hassio_api: true
map:
- type: addon_config
read_only: false
- type: share
read_only: false
- type: ssl
backup: cold
backup_exclude:
- "**/logs"
ports:
5230/tcp: 5230
ports_description:
5230/tcp: Web UI
image: fabioogaravini/hassio-{arch}-memos
Binary file added memos/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added memos/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
45 changes: 45 additions & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/init-addon-config/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/command/with-contenv bashio
# shellcheck shell=bash

set -e

bashio::log.blue "Loading env variables:"

OPTIONS_SOURCE=/data/options.json

mapfile -t arr < <(jq -r 'keys[]' "${OPTIONS_SOURCE}")

for KEYS in "${arr[@]}"; do
# export key
VALUE=$(jq ."$KEYS" "${OPTIONS_SOURCE}")

# Continue for single values
VALUE="${VALUE//[\"\']/}"
line="${KEYS}=${VALUE}"

# text
if [[ "${KEYS}" == *"PASS"* ]] || [[ "${KEYS}" == *"ENCRYPTION"* ]]; then
bashio::log.blue "${KEYS}=******"
else
bashio::log.blue "$line"
fi

export "$line"

# set .env
echo "$line" >> /.env || true

# set /etc/environment
echo "$line" >> /etc/environment

# For s6
if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi
echo "export ${KEYS}=${VALUE}" >> ~/.bashrc
done

if [ -n "$TZ" ] && [ -f /etc/localtime ]; then
if [ -f /usr/share/zoneinfo/"$TZ" ]; then
bashio::log.blue "Timezone set from $(cat /etc/timezone) to $TZ"
ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" >/etc/timezone
fi
fi
1 change: 1 addition & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/init-addon-config/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/init-addon-config/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-addon-config/run
Empty file.
12 changes: 12 additions & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/svc-memos/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/command/with-contenv bashio
# shellcheck shell=bash

mkdir -p "$MEMOS_DATA"

until su postgres -c 'pg_isready' &> /dev/null; do
sleep 5
done

bashio::log.info "Starting Memos"

exec /usr/local/memos/memos
1 change: 1 addition & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/svc-memos/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
1 change: 1 addition & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/svc-memos/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/svc-pocketbase/run
Empty file.
14 changes: 14 additions & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/svc-postgresql/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/command/with-contenv bashio
# shellcheck shell=bash

bashio::log.info "Starting PostgreSQL $PG_MAJOR"

# make db config folder
mkdir -p "$PGDATA" "/config/logs/postgres"

# permissions
chown postgres:postgres -R "$PGDATA" "/config/logs/postgres"
chmod 700 -R "$PGDATA"
chmod 755 -R "/config/logs/postgres"

exec s6-setuidgid postgres postgres-entrypoint.sh postgres -c log_directory="/config/logs/postgres" -c log_rotation_size=10MB
1 change: 1 addition & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/svc-postgresql/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
1 change: 1 addition & 0 deletions memos/rootfs/etc/s6-overlay/s6-rc.d/svc-postgresql/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/svc-postgresql/run
Empty file.
Empty file.
Loading

0 comments on commit ce28539

Please sign in to comment.