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

Instructions for creating docker container #9

Open
moorsey opened this issue Feb 3, 2021 · 10 comments
Open

Instructions for creating docker container #9

moorsey opened this issue Feb 3, 2021 · 10 comments

Comments

@moorsey
Copy link

moorsey commented Feb 3, 2021

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
Copy link

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

@moorsey
Copy link
Author

moorsey commented May 19, 2021

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
Copy link

Thanks for this.

@obbardc
Copy link

obbardc commented Jan 13, 2023

fixed in #31

@Hoffelhas
Copy link
Owner

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

@moorsey
Copy link
Author

moorsey commented Jan 16, 2023

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
Copy link

obbardc commented Jan 16, 2023

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
Copy link
Author

moorsey commented Jan 24, 2023

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
Copy link
Owner

Reopening for now, this might be related to #34

@Hoffelhas Hoffelhas reopened this Jan 29, 2023
@moorsey
Copy link
Author

moorsey commented Jan 6, 2024

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

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

5 participants