Skip to content

Add Dockerfile #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2016
Merged

Add Dockerfile #378

merged 2 commits into from
Oct 30, 2016

Conversation

adamgibbins
Copy link
Contributor

@adamgibbins adamgibbins commented Oct 9, 2016

This adds @yegle's Dockerfile to the contrib directory, preserving all history.
Once merged can you please configure an automated hub build in Dockerhub? I'm unable to do this without contrib rights on the repository oddly. This would mean a new image is built on every commit without someone needing to manually trigger.

  1. Head to https://hub.docker.com/u/fava/dashboard/
  2. Create (top left) -> Create Automated Build
  3. GitHub
  4. Click the repository
  5. "Click here to customize"
  6. Set the Dockerfile location

@yagebu
Copy link
Member

yagebu commented Oct 9, 2016

Can you squash the commits into one?

@adamgibbins
Copy link
Contributor Author

Sure - done. Unfortunately cannot retain the original credit doing that, hence I opted to retain originally.

@yagebu
Copy link
Member

yagebu commented Oct 9, 2016

Unfortunately cannot retain the original credit doing that, hence I opted to retain originally.

You can actually, I usually use rebase -i to do the squashing which will retain the original commit author and just add you as the committer.

&& git clone https://github.com/aumayr/fava.git \
&& (cd fava && git log -1) \
&& make -C fava build-js \
&& rm -rf fava/fava/static/node_modules \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use make clean here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& python3 -mpip install ./beancount \
&& git clone https://github.com/aumayr/fava.git \
&& (cd fava && git log -1) \
&& make -C fava build-js \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the build-js can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm? I can't build it without that:

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python3.5/site-packages/pip/commands/install.py", line 299, in run
    requirement_set.prepare_files(finder)
  File "/usr/local/lib/python3.5/site-packages/pip/req/req_set.py", line 370, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/local/lib/python3.5/site-packages/pip/req/req_set.py", line 587, in _prepare_file
    session=self.session, hashes=hashes)
  File "/usr/local/lib/python3.5/site-packages/pip/download.py", line 798, in unpack_url
    unpack_file_url(link, location, download_dir, hashes=hashes)
  File "/usr/local/lib/python3.5/site-packages/pip/download.py", line 676, in unpack_file_url
    shutil.copytree(link_path, location, symlinks=True)
  File "/usr/local/lib/python3.5/shutil.py", line 353, in copytree
    raise Error(errors)
shutil.Error: [('/root/fava/CHANGES', '/tmp/pip-y5627i91-build/CHANGES', "[Errno 95] Not supported: '/tmp/pip-y5627i91-build/CHANGES'")]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh maybe not, apologies - seems something in the pipeline has started flickering at the most inconvenient time, sigh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aumayr sorry for the delayed turn around on this. I'm having a trouble building recent versions of fava with python3 -mpip install ./fava - I get the above error, my python knowledge is near non-existant so it's highly possible I'm missing something obvious.

It looks like it's attempting to process the CHANGES file for some odd reason? Do pip packages have associated changelogs? Either way, it's not happy with it - any guesses as to why? Irritatingly I'm not able to reproduce this outside of the alpine container - it works fine on my box.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was having the same issue here when trying to update yegle/fava docker image. I'm familiar with Python but not very much with Docker, so I'm not sure what happened here.

A quick&dirty solution would be delete the CHANGES file before python3 -mpip install ./fava, but I'm curious to know why it fail here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The symlink seems to cause problems with ancient versions of pip, which version are you using?

build-js is part of the default build target, so make -C fava is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upstream image uses pip 7.1.2, latest seems to be 8.1.2, maybe that's the issue.

re build-js ah, sorry misinterpreted your original comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upstream image uses pip 7.1.2, latest seems to be 8.1.2, maybe that's the issue.

Hmm the bug I saw should have been fixed in 1.5.... Maybe it's something else then, but maybe try if upgrading pip first fixes it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to do python -mpip install -U pip before doing pip install fava, doesn't work either :-(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pypa/pip#1006 It seems to be fixed long ago, not sure why it resurfaced now.

@aumayr aumayr added the feature label Oct 17, 2016
@aumayr aumayr added this to the 1.1 milestone Oct 18, 2016
yegle and others added 2 commits October 24, 2016 13:53
Additionally switch to the default make task for future proofing and use
make clean instead of cleaning up manually.
@adamgibbins
Copy link
Contributor Author

Alright, force pushed CHANGES workaround and suggested changes.

@yagebu
Copy link
Member

yagebu commented Oct 30, 2016

Once merged can you please configure an automated hub build in Dockerhub?

I'm against this as long as the Dockerfile installs from master. We don't want to distribute that.

@yagebu yagebu merged commit 80f540c into beancount:master Oct 30, 2016
@adamgibbins
Copy link
Contributor Author

@yagebu even if you tag it as unstable? IMO the big advantage to getting it within the official fava repo was so we could do this. Without this people have to maintain their own forks and manually hit build every time fava changes -- there's no way of making it automated through the hub. This means you end up with binary blob images that aren't traced back to dockerfiles, so there's no way to verify the integrity. This was the problem I had with yegle's, I'd have to poke him to hit build on the hub, use a stale HEAD or push to my own hub user and build it there.

Would you be happy with this if we had one that tracked the stable releases too?

@aumayr
Copy link
Member

aumayr commented Oct 30, 2016

I'm for maintaining/building two versions:

  • A stable one for each release, and tagged as such (as many other Docker images do, with -latest and -1.0.0, etc.).
  • An unstable one, tagged as such, for the exact reasons @adamgibbins gives.

@adamgibbins adamgibbins deleted the docker branch October 30, 2016 16:15
@yagebu
Copy link
Member

yagebu commented Oct 30, 2016

Can someone address my concerns that I already posed in #332?:

The dockerfile only installs Fava and doesn't really do anything that running Fava from the command line can't do, right? I've not used Docker before so I might not be aware of some of the advantages of it in this use-case, but it seems to me that it just adds a layer of complexity. How is it easier than running pip3 install beancount-fava?

Of all the ways of distributing an end-user command-line executable, Docker just seems to be the shittiest one.

@yagebu
Copy link
Member

yagebu commented Oct 30, 2016

One should only have to install from master to code or help debugging, which is impossible with the Dockerfile. We had too long gaps between releases so it took too much time for features to land in the released versions, but since 1.0 I plan to something like monthly releases, so this shouldn't be a problem anymore.

@aumayr
Copy link
Member

aumayr commented Oct 30, 2016

How is it easier than running pip3 install beancount-fava?

To avoid problems with dependencies there are AFAIK two solutions:

  • Use virtualenv
  • Use Docker

When I do have to install it on machines that are not dev-machines (like my mom's laptop) it is really a PITA to install all dependencies: Get Python 3 onto that machine and then all the dependencies (I don't think Xcode is necessary anymore for building/installing beancount).

With Docker this get's way easier: Download Docker, and then just get the Fava image and set Docker to start on startup.

That is also the reason I started to wrap Fava in Electron => to make it easier to install and more accessible.

I agree that this might not be necessary for an unstable version (as the described use case is just relevant for stable releases), but I guess there are people who just want to try out Fava or something new we develop on master to join the discussion, without the hassle of setting up a proper development environment.

@aumayr
Copy link
Member

aumayr commented Oct 30, 2016

We had too long gaps between releases so it took too much time for features to land in the released versions, but since 1.0 I plan to something like monthly releases, so this shouldn't be a problem anymore.

🎉

@yagebu
Copy link
Member

yagebu commented Oct 30, 2016

You have some good points. I still think that using Docker is the wrong solution to these problems. PyInstaller offers us a way to build a single executable that users then just have to run, I find that much superior to Docker. If we want to provide a simpler way to install it, we should setup a way to build those, not use Dockerfile as a half-hearted stopgap measure.

@aumayr
Copy link
Member

aumayr commented Oct 30, 2016

PyInstaller offers us a way to build a single executable that users then just have to run, I find that much superior to Docker.

Agreed! Do you have ideas how to automate building them?

@aumayr
Copy link
Member

aumayr commented Oct 30, 2016

(Aside: The absolute dream-setup would be combining PyInstaller with Electron => Fava could be a simple .app/.exe that normal users can download and run, without worrying/knowing about Python/pip/dependencies/etc.)

@yagebu
Copy link
Member

yagebu commented Oct 30, 2016

Agreed! Do you have ideas how to automate building them?

Not sure how to best do it. borgbackup/borg offers PyInstaller binaries and uses Vagrant to build them. Alternatively, we could build them on Travis.

@yagebu
Copy link
Member

yagebu commented Oct 30, 2016

(Aside: The absolute dream-setup would be combining PyInstaller with Electron => Fava could be a simple .app/.exe that normal users can download and run, without worrying/knowing about Python/pip/dependencies/etc.)

fava-electron does already use PyInstaller ;) And electron-builder does a great job of building an installer, but similar to here, we have to find a good way to build cross-platform... (and make fava-electron just slightly more usable)

@yegle
Copy link
Contributor

yegle commented Oct 30, 2016

(Chime in to offer my opinion regarding docker vs package fava into an app)

I started dockerize fava due to various reasons. First, it used to be the case that beancount have new features in tip but not on PyPI, and beancount from tip might be incompatible with fava from PyPI (I forgot if I did encounter an incompatibility though, it was long ago). Second, I need to share fava UI with my wife while I'm the one adding transactions to beancount file, with a NAS at home I can host fava in docker easily.

With docker, I edit the bean file on my laptop and then use Dropbox to sync it to my NAS. My wife can then open fava on the NAS to view all my changes in near realtime.

Using a tool to package fava into an executable doesn't seem to solve my problem, I still need to find a way to sync the bean file to my wife's laptop.

@yagebu
Copy link
Member

yagebu commented Nov 1, 2016

Using a tool to package fava into an executable doesn't seem to solve my problem, I still need to find a way to sync the bean file to my wife's laptop.

How does Docker help with this? I thought you use Dropbox for the syncing, why wouldn't that work with a Fava executable?

@yegle
Copy link
Contributor

yegle commented Nov 1, 2016

@yagebu Syncing a set of files using Dropbox to multiple devices to be used by fava binary is not easy unless every device uses the same root directory, which is impossible with different OS (Windows/macOS).

Hosting it on a server in a docker also has the advantage that I can access via my tablet/phone etc.

@yagebu
Copy link
Member

yagebu commented Nov 2, 2016

Syncing a set of files using Dropbox to multiple devices to be used by fava binary is not easy unless every device uses the same root directory, which is impossible with different OS (Windows/macOS).

I don't quite understand, if you start the binary on a different machine, you can specify a different path to the file.

Hosting it on a server in a docker also has the advantage that I can access via my tablet/phone etc.

Ok but than that's quite a different use-case from the one that this Dockerfile here tries to solve.

@aumayr
Copy link
Member

aumayr commented Nov 11, 2016

For me, having fava in Docker allows me to easily add HTTPS and Auth to it, so this is really helpful for a more "complex" setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants