How to install apps with Docker on Yunohost (how I did it)

Hi! I am excited that I was able to install an app with Docker on Yunohost, so I’d like to share how I did it. I am no developper, so I am not sure if I did everything the right way.

I installed the newest version of Trilium Notes as this app does not seem to work well with YH, the recent updates failed: Update to version 0.52.3 by Jules-Bertholet · Pull Request #23 · YunoHost-Apps/trilium_ynh · GitHub

  1. So first I installed Docker Install Docker Engine on Debian | Docker Documentation

  2. Then add a new domain for the app and the Letsencrypt certificate in the YH webadmin

  3. Install MyWebapp in the YH webadmin

  4. Run the docker command of your app.
    In my case I had to create the necessary folder first

mkdir /home/TheNomad11/trilium-data

then for Trilium

docker run -d -p 0.0.0.0:6080:8080 -v /home/TheNomad11/trilium-data:/root/trilium-data --name trilium zadam/trilium:0.53.2 && docker exec -t -i -u root trilium chown -R node:node /root/trilium-data && docker stop trilium && docker run -d -p 0.0.0.0:6080:8080 -v /home/TheNomad11/trilium-data:/home/node/trilium-data zadam/trilium:0.53.2
  1. Edit the nginx-configuration of the domain your app uses, copy and paste the nginx proxy from the app installation instruction.

In case for Trilium: Nginx proxy setup · zadam/trilium Wiki · GitHub

You just need to replace the domain and the port and don’t forget YH-specific parts of the configuration

In my case it looks like this:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}



# This part is for proxy and HTTPS configure
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name trilium.my-yunohost-domain.com;

    
    
   include /etc/nginx/conf.d/security.conf.inc;

    ssl_certificate /etc/yunohost/certs/trilium.my-yunohost-domain.com/crt.pem;
    ssl_certificate_key /etc/yunohost/certs/trilium.my-yunohost-domain.com/key.pem;
 
    location / {
        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;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://localhost:6080; #change it to your IP and port
        proxy_read_timeout 90;
        proxy_redirect http://localhost:6080 https://trilium.my-yunohost-domain.com; #change them based on your IP, port and domain
    }
}
# This part is for HTTPS forced
server {
            listen 80;
            server_name trilium.my-yunohost-domain.com; # change to your domain
            return 301 https://$server_name$request_uri;
}





server {

 
    
    

    location ^~ '/.well-known/autoconfig/mail/' {
        alias /var/www/.well-known/trilium.my-yunohost-domain.com/autoconfig/mail/;
    }

    access_by_lua_file /usr/share/ssowat/access.lua;

    include /etc/nginx/conf.d/trilium.my-yunohost-domain.com/*.conf;

    include /etc/nginx/conf.d/yunohost_sso.conf.inc;
    include /etc/nginx/conf.d/yunohost_admin.conf.inc;
    include /etc/nginx/conf.d/yunohost_api.conf.inc;

    access_log /var/log/nginx/trilium.my-yunohost-domain.com-access.log;
    error_log /var/log/nginx/trilium.my-yunohost-domain.com-error.log;
}

# vhost dedicated to XMPP http_upload
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name xmpp-upload.trilium.my-yunohost-domain.com;
    root /dev/null;

    location /upload/ {
        alias /var/xmpp-upload/trilium.my-yunohost-domain.com/upload/;
        # Pass all requests to metronome, except for GET and HEAD requests.
        limit_except GET HEAD {
          proxy_pass http://localhost:5290;
        }

        include proxy_params;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'HEAD, GET, PUT, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'Authorization';
        add_header 'Access-Control-Allow-Credentials' 'true';
        client_max_body_size 105M; # Choose a value a bit higher than the max upload configured in XMPP server
    }

    include /etc/nginx/conf.d/security.conf.inc;

    ssl_certificate /etc/yunohost/certs/trilium.my-yunohost-domain.com/crt.pem;
    ssl_certificate_key /etc/yunohost/certs/trilium.my-yunohost-domain.com/key.pem;

    
    

    access_log /var/log/nginx/xmpp-upload.trilium.my-yunohost-domain.com-access.log;
    error_log /var/log/nginx/xmpp-upload.trilium.my-yunohost-domain.com-error.log;
}


  1. Restart or reload Nginx and voila, it’s done!

Does this look okay? For me at least, it works!

1 Like

I just did a similar thing, but I used the redirect app to create an app tile in the SSO that redirects to custom ports. Works well too :slight_smile:

2 Likes