Hoffelhas / autodoist

Added functionality for Todoist.
MIT License
178 stars 24 forks source link

Instructions for creating docker container #9

Open moorsey opened 3 years ago

moorsey commented 3 years ago

Sorry, not sure if this is the best way to get this info added to the readme, bit lost on the whole github thing

Anyway, I have successfully created this app inside a docker container, running happily

Guide assumes you have docker installed

  1. Make sure labels already exist in Todoist, as this will not be running interactively, so you can’t say “Yes” to “do you want to create required labels”. These will depend on what settings you are using. For example, regen ones are: "Regen_off", "Regen_all", "Regen_all_if_completed"
  2. Make a working directory for your autodoist script / files
  3. Download the latest version of autodoist from https://github.com/Hoffelhas/autodoist
  4. Extract to your working directory
  5. Create a file called dockerfile with the following contents:
FROM python:3.9.1

WORKDIR /app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY autodoist.py /app
CMD [ "python", "autodoist.py", "-a=API_KEY_HERE", "-r=2", "-l=next", "-hf=8" ]

Note, replace the last line with your API key and required options. Each option must be in quotes and separated with a comma

  1. Move to your working directory and run docker build -t autodoist-image ., where autodoist-image is the name that will be given to your new docker image

The python files will be downloaded and then the requirements.txt will be processed, to install pre-requisites for autodoist inside the image

  1. Create the docker container by running:
docker run -d \
--name=autodoist-container \
--restart unless-stopped \
autodoist-image

Replacing docker options as needed

You can now watch the logs of the container, to check for errors, or if it is running happliy

goncalomcorreia commented 3 years ago

Thank you! Can you use this to keep autodoist running in the background and on system startup?

moorsey commented 3 years ago

Yes correct, I have this running on my home server, set and forget

Getting to know a bit about docker would be your starting point though, depends on your OS etc

jleseane23 commented 2 years ago

Thanks for this.

obbardc commented 1 year ago

fixed in #31

Hoffelhas commented 1 year ago

Pull request #31 has been included in the latest master release. Thanks for the help @obbardc! Closing this tracker for now.

moorsey commented 1 year ago

Thanks for making someing proper for this @obbardc

Forgive me though, I'm not sure how to run it now. Can it now be ran with variables for API key etc?

I've ran as follows so far:

git clone https://github.com/Hoffelhas/autodoist.git
cd autodoist
docker build . --tag autodoist:latest
docker run -it autodoist:latest

The last command fails of course, as the API key is missing

Sorry for the noob understanding level here!

obbardc commented 1 year ago

Thanks for making someing proper for this @obbardc

Forgive me though, I'm not sure how to run it now. Can it now be ran with variables for API key etc?

I've ran as follows so far:

git clone https://github.com/Hoffelhas/autodoist.git
cd autodoist
docker build . --tag autodoist:latest
docker run -it autodoist:latest

The last command fails of course, as the API key is missing

Sorry for the noob understanding level here!

Hey, building is optional, you can just run it as follows:

docker run -it -e TODOIST_API_KEY=??? ghcr.io/hoffelhas/autodoist:latest --label Next --hide_future=8

untested but it should work. I personally run it with docker-compose like:

version: "3.7"
services:
  autodoist:
    image: ghcr.io/hoffelhas/autodoist:latest
    container_name: autodoist
    env_file: secrets/autodoist.env
    command: --label Next --hide_future=8
    restart: unless-stopped

I didn't manage to update the README due to lack of time, maybe you could do that in a PR ?

moorsey commented 1 year ago

Thanks, I will add to the readme for sure, once I have a full grasp of it!

Do you have a list of the variables accepted? Not entirely sure how to glean this from the code, regen (although think this is disabled currently) and end of day for example

In your compose, I assume the .env file just has TODOIST_API_KEY=asdfg inside?

I tried a docker run, but get an API error currently, possibly not an issue with the docker as such

docker run -it -e TODOIST_API_KEY=*** ghcr.io/hoffelhas/autodoist:latest --label next --hide_future=2

2023-01-24 06:55:29 INFO     You are running with the following functionalities:

   Next action labelling mode: Enabled
   Regenerate sub-tasks mode: Disabled
   Shifted end-of-day mode: Disabled

2023-01-24 06:55:32 INFO     Autodoist has successfully connected to Todoist!
2023-01-24 06:55:32 INFO     SQLite DB has successfully initialized!

2023-01-24 06:55:37 ERROR    Error trying to sync with Todoist API: 400 Client Error: Bad Request for url: https://api.todoist.com/sync/v9/sync
Traceback (most recent call last):
  File "/usr/src/app/./autodoist.py", line 521, in sync
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.todoist.com/sync/v9/sync
Hoffelhas commented 1 year ago

Reopening for now, this might be related to #34

moorsey commented 8 months ago

Just dropping my working docker-compose here for reference

version: "3.7"
services:
  autodoist:
    image: ghcr.io/Hoffelhas/autodoist:latest
    container_name: autodoist
    command: -l=next -hf=2 -a=1234567890**apikey**abcdefg
    restart: unless-stopped