memos is a free, open source, and self-hosted memo hub. You can post your ideas, code, todo list, whatever, on it, just like a personal facebook. Recently, memos released "Ask AI," which allows you to have a conversation with GPT. This article introduce how to deploy memos within a docker container and add OpenAI API to memos to support GPT.

Demo

My memos.

Deployment

Install and run memos in docker container

Install docker and docker compose if they haven't been installed yet.

curl -sSL https://get.docker.com/ | sh
systemctl enable --now docker

Create docker-compose.yml.

version: "3.5"

services:
    memos:
        image: neosmemo/memos:latest
        restart: unless-stopped
        container_name: memos
        volumes:
            - ./memos/:/var/opt/memos
        ports:
            - 127.0.0.1:5230:5230

Then up docker compose.

docker compose up -d

Access IP:5230 to check if memos runs successfully.

Configure nginx

Add a nginx configuration for memos like follows. If you don't have a domain certificate yet, see here and here.

server {
    listen 443 ssl http2;
    server_name memos.domain.com;

    ssl_certificate     PATH/server.crt;
    ssl_certificate_key PATH/server.key;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers         ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on; 
    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 10m;

    location / 
    {   
        proxy_pass          http://127.0.0.1:5230;
        proxy_set_header    Host $host;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto $scheme;
    }   
}

server {
    listen              80;
    server_name         memos.domain.com;
    return              301 https://$host$request_uri;
}

Restart nginx to reload new configuration.

nginx -s reload

Now, memos can be accessed by domain.

Some operations

Update

docker compose down && docker image rm neosmemo/memos:latest && docker compose up -d

Backup

tar -czvf memos-backup-$(date +%Y-%m-%d).tar.gz memos

Add OpenAI API key to memos

Visit this webpage and log in.

Create new secret key.

Add OpenAI API to memos.

Now, you can talk with your AI friend 🤖.

Outline