Skip to content
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

How to configure in Docker? #4

Open
MatthK opened this issue Sep 16, 2021 · 7 comments
Open

How to configure in Docker? #4

MatthK opened this issue Sep 16, 2021 · 7 comments

Comments

@MatthK
Copy link

MatthK commented Sep 16, 2021

I managed to get the docker compose up and running and I can login. I first failed to get it running on my Raspberry Pi 4, and I also failed to point the DB to an existing MySql container. But when I eventually tried your vanilla setup, it worked at first try.

One other little issue I found is that I couldn't set the APPLICATION_SECRET with the normal user, and start the docker with sudo docker-compose up -d. But that's not a real issue.

But now I am trying to configure the app and setup some categories and accounts, but I can't find the conf directory. How can I map that volume to a local directory?

Also, how can I change the EUR sign into a $?

@nymanjens
Copy link
Owner

I managed to get the docker compose up and running and I can login. I first failed to get it running on my Raspberry Pi 4, and I also failed to point the DB to an existing MySql container. But when I eventually tried your vanilla setup, it worked at first try.

Hmm, thanks for letting me know. I never use the Docker way myself, and I'm a bit of a Docker novice anyway, which probably explains why it may be a bit rough using it. I'm happy to accept pull requests if you have a better way of configuring it.

But now I am trying to configure the app and setup some categories and accounts, but I can't find the conf directory. How can I map that volume to a local directory?

I guess that's a flaw in docker-compose.yml that it doesn't map the conf folder to a local folder. You probably have to do that.

For the vanilla setup, it's easy: You just edit conf/accounting-config.yml

Also, how can I change the EUR sign into a $?

You'll have to change this field in Currency.scala#L27

And then you'll have to (unfortunately) compile the whole thing. You need the scala builder (sbt) and node.js for this. In case you want to use Docker for that, here is a Dockerfile for compiling another project of mine that works with the same framework: https://github.com/nymanjens/quizmaster/blob/master/Dockerfile
(I think it should translate exactly to facto)

@MatthK
Copy link
Author

MatthK commented Sep 17, 2021

I did make some progress, but still failed in the end.

I managed to get the conf directory mapped in the docker-compose. And I also made a change to the Database volume, so basically all the data would be in one place.

However, I couldn't make basic changes to the accounting-config.yml to adjust some categories or accounts, and mostly replace the users Alice and Bob with my wife and myself. Whenever I replace Alice and Bob with two other names, I keep getting a console error saying that No user exists with loginName 'matth'. But I have defined such a user.

And I haven't even tried to get to the compiling yet. I fear I will give up and look for another solution.

In case somebody else is interested, this is the docker-compose.yml that is working.

version: "3.3"

services:
  db:
    container_name: MariaDB
    image: mariadb:10.3
    volumes:
    - /facto_data/db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: facto
      MYSQL_DATABASE: facto

  web:
    container_name: Facto
    depends_on: [db]
    command: bin/server
    image: nymanjens/facto:latest
    ports: ["9000:9000"]
    restart: always
    environment:
      APPLICATION_SECRET: long_and_secret_string
      DATABASE_URL: jdbc:mysql://db:3306/facto?user=root&password=facto&disableMariaDbDriver
    volumes:
    - /facto/facto_data/conf:/app/conf

I also copied a bunch of files over from the /app/conf directory into my data directory, as those are not in the Git-files, but I found them in the docker container.

accounting-config.yml
application.conf
messages
messages.nl
routes
serviceWorker.template.js

The application.conf file has the following values:

# Secret key
# ~~~~~
play.http.secret.key = "long_and_secret_string"

# The application languages
# ~~~~~
play.i18n.langs = ["en"]

# MySQL database:
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://db:3306/facto?user=root&password=facto&disableMariaDbDriver"
db.default.slick.profile = "slick.jdbc.MySQLProfile$"

app.setup.defaultPassword = "long_secret_password"
app.accounting.configYamlFilePath = "/app/conf/accounting-config.yml"

@nymanjens
Copy link
Owner

Hi!

No user exists with loginName 'matth'. But I have defined such a user.

This is probably a bit of a confusing error message and I added a TODO to make this more clear (or make it easier to fix). The problem is that your MySQL database needs to have a user that you can then tie to an account in the config file. So you first need to get the server running, add users for you and your wife and only then link the accounts to users. You can easily add users via the web UI.

In case somebody else is interested, this is the docker-compose.yml that is working.

Thanks, I'll probably update the docker-compose in the project with yours.

I also copied a bunch of files over from the /app/conf directory into my data directory, as those are not in the Git-files, but I found them in the docker container.

Hmm, so the issue is that the demo config files are not checked in. This can be fixed.

It seems to be clear that the whole Docker flow is pretty much untested. It makes me think it would be better to only provide the "Installation from release" option, which I think should work a lot better.

nymanjens added a commit that referenced this issue Sep 17, 2021
@MatthK
Copy link
Author

MatthK commented Sep 17, 2021

This is probably a bit of a confusing error message and I added a TODO to make this more clear (or make it easier to fix). The problem is that your MySQL database needs to have a user that you can then tie to an account in the config file. So you first need to get the server running, add users for you and your wife and only then link the accounts to users. You can easily add users via the web UI.

But I am certain, that I have defined the users in the system. I first only had a user for myself, so it complained about my wife. But then I added her user too, and it then still came up with the error. I also tried it with all lowercase (matth) and with a first capital letter (Matth). This was as the user record was shown in the database view under loginName.

Although I don't have that much experience with Docker, I start to prefer solutions that offer a docker container. It's usually so much easier to install, and simpler.

@Julius112
Copy link

I'm currently evaluating the tool. To quickly test it, I've used the docker-compose.yml from the Readme of this repo and ran the commands provided by the Readme.
After that, I've created the users in the database over the UI and shut down the (docker-compose) services.
Then I ran:
docker-compose cp web:/app/conf/accounting-config.yml accounting-config.yml
to retrieve the accounting-config.yml

I edited the file and used the following command to upload the file back into the container filesystem:
docker-compose cp accounting-config.yml web:/app/conf/accounting-config.yml

After a restart, everything seemed to work. I just wanted to let you know that it seems to work. In case I stick with the tool, I might actually write a Helm Chart for it to host it in a Kubernetes Cluster. That's where I would run it myself as well.

@Hukuma1
Copy link

Hukuma1 commented Sep 10, 2024

Been quite a few years. Any chance of a revisit for an official Docker install method? And was the ability to change currency from euro to dollar ever made easier? Thank you!

@nymanjens
Copy link
Owner

I'm happy to receive PRs for a better Docker setup/instructions and the ability to change the default currency without having to recompile the code.

It is unlikely that I will find the time and motivation to do so.

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

No branches or pull requests

4 participants