sajozsattila/mur2_editor

Missing build instructions

johnblommers opened this issue · 12 comments

Would you be able to document how to install μr2 so we can self-host it?

Definitely, and it is planned.

But before I can do it, I still need to make some decision. We run the editor as part of a Flask based server at the moment, where another project also included. Some part of the full codebase is not connected to the editor at all there. Example Open-Access Article search engine. But some of the used by both project, but strictly speaking not part of the editor. Example user authentication.

I have not decided yet where should be the cutoff point in the code, should I include these shared codes here or not? For just the editor there is no need for them. However, there is some function which is work just after login. Example: saving the documents in DB. But including them also means including a branch of other dependencies, like DB. Also, it restricts people to use their authentication method etc.

I am actively thinking about these questions, and when I decided one way than another I will refactor the code, and make the installation document.

In the main time if you have a Flask server you can include the content of the app directory there and the editor should work.

So I installed Flask

sudo apt install python3-flask

Then I cloned this repository and:

cd ~/Applicatons
git clone https://github.com/sajozsattila/mur2_editor.git
cd mur2_editor
cd app
flask run
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Usage: flask run [OPTIONS]

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

Can you suggest a value FLASK_APP be assigned?

If you not familiar with the Flask it could be a little bit difficult, to explain. I try to build a Docker image for you in the next week, probably this will save a lot of time for you and me also.

All right, no problem, and thank you. I had not heard of Flask until you mentioned it and installed it to self-host μr2 editor. A docker solution would certainly be easier to distribute to testers. An AppImage might be an alternative to consider.

Have a look: https://github.com/sajozsattila/mur2_docker.

This is not a final version but should be working. I have to do some code refactoring, and it was easier to do in the current developing branch (1.7.2) of the editor than in the stable (1.7.1).

When I will roll out the 1.7.2 I will refactor the docker image to be configurable the editor code version.

Not exactly a small docker: 8.2G. The main reason for this is including a full LaTeX and pandoc install.

The Docker container built successfully:

...
Successfully built 6abf7d3f68f8
Successfully tagged mur2/pandoc:1.0.11

docker images
REPOSITORY    TAG          IMAGE ID       CREATED          SIZE
mur2/pandoc   1.0.11       6abf7d3f68f8   30 minutes ago   7.78GB
hello-world   latest       d1165f221234   2 months ago     13.3kB

But from the instructions:

docker run --name mur2_docker -p 8000:8000 mur2_docker:1.7.2
Unable to find image 'mur2_docker:1.7.2' locally
docker: Error response from daemon: pull access denied for mur2_docker, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.

There should be two images: mur2/pandoc and mur2/mur2_docker. Have you done the 2nd step?

I should have gone back and updated. I did forget the second step but recognized my error and completed it as well.

sudo docker images

REPOSITORY      TAG          IMAGE ID       CREATED         SIZE
mur2_docker     1.7.2        737a1d309773   20 hours ago    8.38GB
mur2/pandoc     1.0.11       6abf7d3f68f8   21 hours ago    7.78GB
hello-world     latest       d1165f221234   2 months ago    13.3kB
python          3.8.2-slim   e7d894e42148   13 months ago   194MB
sridca/neuron   latest       72d91c2c2c81   51 years ago    184MB
sudo docker run --name mur2_docker -p 8000:8000 mur2_docker:1.7.2
Configuration
[object Object]
Mur2 Makrdown-it server is listening at http://localhost:3000
/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:851: UserWarning: Neither SQLALCHEMY_DATABASE_URI nor SQLALCHEMY_BINDS is set. Defaulting SQLALCHEMY_DATABASE_URI to "sqlite:///:memory:".
  warnings.warn(
/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:872: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
  warnings.warn(FSADeprecationWarning(
[2021-05-25 00:23:21,830] INFO in __init__: Flask example startup
INFO:waitress:Serving on http://0.0.0.0:8000

Now port 8000 is active but all I see in the web browser (I tried Brave, Firefox and Google Chrome) is:

{"name":"mur2_docker","version":"1.0.0"}

Sorry, I was missing the full address in the documentation. I have just updated the docker README. The correct address: http://localhost:8000/editor .

The above address the / of the flask server, and it is showing indeed it is running. But how I mentioned this project is part of another one, so to make it possible to integrate, it is not running on the root address.

Excellent. http://localhost:8000/editor does indeed connect to the editor. At this juncture I am quite satisfied that I can now self-host the editor.

Question As I don't wish you to spend a great deal of your time worrying about packaging I'll sit back for a while and leave you to work on the editor. At some juncture I assume it will be necessary to update the Docker container. Will that entail another 90-odd minutes of building a roughly 8 GB container or will there be an update procedure that's faster? No pressure.

As you indicated this docker container represents a development branch and that's fine for now. There is a cosmetic issue in that the text in the editor pane is white on white or grey on grey depending on the theme:

Screenshot from 2021-05-25 19-33-35

You can see where I have selected some of the text in the editor pane to illustrate the issue.

This is reproducible for Firefox, Min, Opera, Vivaldi, Brave and Google Chrome. But that is another matter.

Thanks for reporting the problem, I will investigate.

About the update: The "mur2_pandoc" is the bigger images, and there is a full TexLive and Pandoc install. This docker needs to rebuild when these two have a major update. It is a little bit out of my hand. I try to keep these images up-to-date but do not really matter if they little bit out.

The other image "mur2_docker" is the content of the actual editor. This need to build every time when the editor has a new version.

So most of the time I am expecting you need just rebuild the "mur2_docker", which is significantly faster than building both.

I made the changes on the mur2_docker which I wanted, so it is now dynamically using the code from this git. So I am closing this ticket.

The 1.7.2 still a developing branch, but all of the new function is there which I would like to release, so just testing going on. If everything going ok, next week will be released.