User help for non-Farmer

Hi there.
I am not a farmer. Don’t do landscaping. Can’t even grow seedlings very well.

My client is a landscaper and his client wants to use this software to manage his farm.

I am attempting to enter his data (vineyards, plants, gardens, etc.) in various locations, but do not really understand what is being stored, how to retrieve, etc.

My Main issue is “Intrinsic geometry”. I check the box “Is fixed”, and get a map. when I click my location for - say Alberino Vines - the correct vineyard is highlighted, but where is this info stored ? I never seem to be able to get it back again.

Apart form this, i have no reports.
And when I tri to upload images I always get an upload error.

Is there a trouble shooting wiki or something somewhere ? I need to make some visible progress in the next couple of days, or probably lose this contract.

2 Likes

Welcome @nzsnowman!

It might help to read this section of the farmOS data model documentation, which describes how “asset location” works: Location | farmOS

I would recommend NOT setting “is fixed” for vineyard assets. This may seem counterintuitive, because once a fine is planted then it is more or less “fixed”, but this isn’t exactly what the “is fixed” property means in farmOS. It is intended to be used primarily for assets like “land”, which are part of the geography itself, and therefore have “intrinsic geometry”.

Plant assets, on the other hand, DO move from time to time. I would assume that these vines are no exception, and that they were transplanted at some point. farmOS would model these plant assets even before they get transplanted, and record the transplant as a log that ultimately assigns them their location. This way of modeling things allows for a lot of flexibility - farmOS can represent plants that are direct seeded, started in a greenhouse and transplanted, purchased from a nursery and transplanted, etc etc, and each “movement” of those assets is tracked via logs, so you have the full history over time of where it has been. For many use-cases having this tracking history is important.

And notably, it works the same way consistently across all asset types. Animals, equipment, etc all get their “location” assigned to them by their movement logs. So you can see where everything has been (as well as where it plans to go in the future).

I would also highly recommend you try the “Planting quick form”, which is an optional module that you can enable. This creates a “quick form” for recording plantings, and it will handle creating BOTH the “plant asset” and the “transplanting log” at the same time for you (it can also add “seeding” and “harvest” logs optionally). I think this would work for your vineyard use-case. And it will help to demonstrate how the records should look afterwards.

So the steps I would recommend are:

  1. Map the vineyard with “Land” assets
  2. Use the “Planting quick form” to create the “Plant assets” and “Transplanting logs” to represent the actual vines.

farmOS provides a lot of flexibility around how granular you want to record things. This is up to you, and may depend largely on how the farmer “thinks” about things. For example, you may want a separate plant asset for each “type” (aka variety) of vine, and “area” of vineyard. The more assets you have, the more fine-grained your record keeping can be - but of course, the more data entry is required. So understanding what will be most useful to the farmer you are helping is important.

Hope that helps to clear things up! Highly recommend reading the user guide and data model docs if you haven’t already!

That’s brilliant. Thank you so much. I have read much of the documentation, but a lot doesn’t really mean much until I start using that component.

As I’m not the original landscaper, I don’t have access to any transplanting data, etc. so I guess I can default everything (season, quantities, etc.) to unknown, and let the client enter that data later ?

Do you have any idea why I cannot add images ? The upload just seems to fail no matter what size or format file I choose… where do I got troubleshooting like that ?

Yes - you’ll need to specify a date for the transplanting log, but if you can estimate it, or set it to some standard value in the past, that will work.

I assume you are self-hosting (not using Farmier.com)? In order to upload files you need to configure the “private files directory” by adding a line to your settings.php file.

That’s the basic idea. This is Drupal config, not farmOS specific, so you may be able to troubleshoot by searching for “Drupal private file uploads” etc. There are a few other topics in the forum from folks who worked through it. Happy to help if you’ve already done the above and are still having trouble!

Okay, so I finally obtained access to the server itself, and added:
$settings[‘file_private_path’] = ‘file-path’;
(my file-path is different from the one in the examples; but I checked it exists)
restarted the Docker container, and tried again. Same error, so is there something else I need to do ? Clear the cache or something ??
Normally, I would restart Apache & wait 5 mins to pick up config changes… but I believe the container itself manages all that. No ?

  • What is the owner/group for the private files directory set to?
  • What is the output of docker exec 14216718f9c6 drush php-eval 'print_r([\Drupal\Core\Site\Settings::get("file_private_path")]);' where “14216718f9c6” is the id of the farmOS container (obtainable via docker ps)
2 Likes

(my file-path is different from the one in the examples; but I checked it exists)

If you are using a different directory than the examples, and you are using Docker, the first question I would have is: is your directory being mounted into the Docker container (assuming it is a directory that lives outside of the Docker container for file persistence - it needs to be otherwise you will lose all the files when the container is destroyed).

If it is mounted in, and you are sure that you are referencing the correct file path relative to the Docker container (not relative to your host machine), then the next question would be: is the directory writable by Apache?

You may also find additional details at /admin/config/media/file-system (where you configure the Drupal public/private filesystem paths), or /admin/reports/status (which provides a general status report of the Drupal installation - sometimes flags issues like this).

2 Likes

Thanks guys; I appreciate your help. (time zone differences are a pain, though!)

Result of the docker exec call is:
Array
(
[0] => /docker/farmos/drupal/web/sites/default/files
)
which is a directory I created in a path that seemed similar to the one in the example. I gave it full permissions to avoid any issues.
Possibly that was a mistake; if (as you say. Mike) it ought to be outside the docker container.
I guess I could move it to etc or somewhere more global. Where would you recommend ?

Can you share a little more information about your Docker hosting setup? You mentioned you’re using Plesk in another thread - correct?

I’m not familiar with Plesk, so I’m not sure how much help I can be. But the basic idea of Docker is that it “containerizes” a service, which makes it “ephemeral” - so you can create/destroy the container quickly/easily. Naturally that means that if you are storing any data within the running container, it gets lost when the container gets destroyed. So, you set up “volumes” - directories that are mounted from a specific path on the host into a specific path inside the container - for any data that needs to be “persisted” outside of the container lifecycle.

In the case of farmOS (Drupal), best practice is to persist the whole sites directory. In the farmOS Docker container, that is in /opt/drupal/web/sites. This includes both uploaded files as well as the settings.php file which stores database connection credentials. (So FYI if you aren’t already persisting those, then when you shut down your container it will lose connection to the database.)

Docker Compose is one way to run containers. Our example docker-compose.production.yml file shows the volume mount here: farmOS/docker-compose.production.yml at 616261498d87103eba3651254ac25f9f4cfd0f36 · farmOS/farmOS · GitHub

    volumes:
      - './sites:/opt/drupal/web/sites'

What that means is: “take the sites directory (that is in the same directory as the docker-compose.yml file), and mount as a volume so it’s available at /opt/drupal/web/sites inside the container.”

You will need something similar.

If you currently have /docker/farmos/drupal/web/sites/default/files on your host system, I would recommend mounting /docker/farmos/drupal/web/sites into the container as /opt/drupal/web/sites.

It’s up to you where you keep the directory outside the container. But inside the container it needs to be available at /opt/drupal/web/sites, assuming you are using the standard farmOS Docker image.

Speaking of: what Docker image are you using?

We recommend that you use a specific version (eg: farmos/farmos:2.0.0-beta7), and not latest or 2.x (and especially not 2.x-dev in production deployments).

See: Installing farmOS | farmOS

Yes. We’re using Plesk dashboard, but I have managed to gain access to a SSH Terminal session, so I can do more or less anything I want at a command line level. (but forgive me, it’s been a few decades since I used any flavour of Linux)

I don’t now much about the Docker hosting Setup; we didn’t install it.
When you say “set up volumes” do you just mean create symbolic links to real directories ? Or is this a Docker function ?

Plesk specifies volume mapping; there are currently two:
Container: /opt/drupal - Host: /docker/farmos/drupal
Container: /sites/default - Host: /docker/farmos/sites
But I’m not sure if this is what you meant.

Are you saying that the solution to my file upload issue is a symbolic link (“volume”) inside the container, mapped to a real world directory elsewhere… which I can then reference in my settings.php script ?

So, it might be as simple as adding another Volume in Plesk to point to my “files” directory…

(incidentally, “/docker/farmos/sites” is empty; nothing in there at all)

Yes “volumes” are a Docker concept - not the same as symlinks.

Interesting - who configured those?

If I’m reading it correctly, the first volume (Container: /opt/drupal - Host: /docker/farmos/drupal) suggests that the whole Drupal codebase is being mounted as a volume. This is useful for development but NOT for hosting of a live farmOS instance. It will make upgrades much more difficult.

You really should just have one volume mount to start with… something like Container: /opt/drupal/web/sites - Host: /docker/farmos/sites.

If you change your volumes now you will most likely need to reinstall farmOS. Do you have data in it already that needs to be preserved? If so, you may need to do this a bit more carefully…

Yes, unfortunately, we do have a lot of data, now.
Migrating to a new location would be problematic… unless there’s a cool migration tool (I have a brilliant one for WordPress)
We might have to leave it as is, for now. I will talk to the owner about proper installation, once we have cemented our relationship. (he is my client’s client, at the moment)

… in addition… I have found more than one Settings.php file. Mebbe I edited the wrong one.
I know our file structure is not standard, but roughly where should the Settings.php file be that needs the ‘file_private_path’ set ?

That’s why I provided a command that will tell us where Drupal thinks that path is set to.

That means that you did manage to set it somehow.

You can see that Drupal thinks it should be storing the files at /docker/farmos/drupal/web/sites/default/files. I suspect that means the path is misconfigured since (as Mike pointed out above) you probably want it to be set to something within /opt/drupal/web/sites inside the container. In which case you’d want to set the path in your settings.php file to something like /opt/drupal/web/sites/default/private/files (that’s what I use).

Then when you run docker exec <containerId> drush php-eval 'print_r([\Drupal\Core\Site\Settings::get("file_private_path")]);' it should print out;

Array
(
[0] => /opt/drupal/web/sites/default/private/files
)

Then you’d also want to confirm that when you run docker exec <containerId> ls -lah /opt/drupal/web/sites/default/private it shows that the files directory is owned by the user/group www-data.

e.g.

$ docker exec <containerId> ls -lah /opt/drupal/web/sites/default/private
total 12K
drwxr-xr-x 3 root     root     4.0K Aug 26 18:33 .
dr-xr-xr-x 4 www-data www-data 4.0K Oct  8 15:52 ..
drwxr-xr-x 5 www-data www-data 4.0K Aug 27 13:24 files
1 Like

Ah, gotcha now. I see.
I checked all those permissions, and everything looks fine.
So, just to be safe, I have created ‘private’ under default, and ‘file’ under private and gave it all permissions (777).

Ahh… magic. It works now.

I do get strange errors though when I try to execute:
print_r([\Drupal\Core\Site\Settings::get("file_private_path")]);
it tells me I don’t have “config sync directory” defined. Hope I haven’t broken something else.

Yes, unfortunately, we do have a lot of data, now.

The concern I have is that your settings.php file and any images/files that have been uploaded to records may get lost if you shut down your Docker container and they are not being persisted in a volume properly.

The data in your database should be fine, assuming that is in a different container, AND assuming that the volume is correctly configured on that as well to persist data. Is that a safe assumption?

It’s really important to understand volumes if you are going to host anything with Docker. REALLY important. Can’t understate that… and I just don’t want to see you lose anything!

So until you have a firm grasp on what is/isn’t being persisted, do not shut down or delete your container!

Migrating to a new location would be problematic… unless there’s a cool migration tool (I have a brilliant one for WordPress)

This is more of an issue with files than anything else. Docker containers are ephemeral, so they can be created/destroyed easily. Think of it like a digital camera… the digital camera has all the software on it to take pictures, etc etc, but you need to put a memory card in to save them. The Docker volume is like the memory card. Using this analogy, if you break your camera you can get a new one and just move the memory card over. With Docker, though, if you DON’T use a volume, and you “break” your container, you lose all the data you wanted to keep.

So… when you want to update to a new version of farmOS, the process is: you shutdown your Docker container, pull the new Docker image version, and start up a new Docker container from that image, with your volume mounted in. So the CODE inside the container gets replaced, but the DATA inside the volume persists.

The most important things you need to make sure are persisting for farmOS are:

  • /opt/drupal/web/sites in the farmOS container - for settings.php and uploaded files.
  • /var/lib/postgresql/data in the database container (assuming you are running PostgreSQL in Docker) - for all your farmOS data (assets, logs, users, etc etc).
1 Like