add more environment variables
This commit is contained in:
parent
497d04ad2d
commit
43d2ea6c01
16
Dockerfile
16
Dockerfile
|
@ -7,6 +7,20 @@ RUN pip install colorama
|
||||||
COPY . /app
|
COPY . /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV USE_DOCKER=1
|
||||||
|
ENV YOUR_CONTAINER_NAME="$YOUR_CONTAINER_NAME"
|
||||||
|
ENV I2M_INSTAGRAM_USER="$I2M_INSTAGRAM_USER"
|
||||||
|
ENV I2M_INSTANCE="$I2M_INSTANCE"
|
||||||
|
ENV I2M_TOKEN="$I2M_TOKEN"
|
||||||
|
|
||||||
|
|
||||||
|
ENV I2M_CHECK_INTERVAL "$I2M_CHECK_INTERVAL"
|
||||||
|
ENV I2M_POST_INTERVAL "$I2M_POST_INTERVAL"
|
||||||
|
ENV I2M_USE_MASTODON "$I2M_USE_MASTODON"
|
||||||
|
ENV I2M_FETCH_COUNT "$I2M_FETCH_COUNT"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ENTRYPOINT ["python", "/app/src/main.py", "--instagram-user", I2M_INSTAGRAM_USER, "--instance", I2M_INSTANCE, "--token", I2M_TOKEN, "--check-interval", I2M_CHECK_INTERVAL, "--post-interval", I2M_POST_INTERVAL, "--fetch-count", I2M_FETCH_COUNT, "--use-mastodon", I2M_USE_MASTODON]
|
||||||
|
#ENTRYPOINT ["echo", "--instagram-user", I2M_INSTAGRAM_USER, "--instance", I2M_INSTANCE, "--token", I2M_TOKEN, "--check-interval", I2M_CHECK_INTERVAL, "--post-interval", I2M_POST_INTERVAL, "--fetch-count", I2M_FETCH_COUNT, "--use-mastodon", I2M_USE_MASTODON]
|
||||||
ENTRYPOINT ["python", "/app/src/main.py"]
|
ENTRYPOINT ["python", "/app/src/main.py"]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
bot:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
image: "horhik/instagram2fedi:latest"
|
||||||
|
environment:
|
||||||
|
- YOUR_CONTAINER_NAME=innubis_crossposter
|
||||||
|
- I2M_INSTAGRAM_USER=innubis
|
||||||
|
- I2M_INSTANCE=mastodon.ml
|
||||||
|
- I2M_TOKEN=y-Sz4sICYGwEkTI5UJz2U-58hvjGXec61YSLo2zascQ
|
||||||
|
- I2M_CHECK_INTERVAL=3600 #1 hour
|
||||||
|
- I2M_POST_INTERVAL=3600 #1 hour
|
||||||
|
- I2M_USE_MASTODON=4 #max carouse - is 4, if there's no limit set to -1
|
||||||
|
- I2M_FETCH_COUNT=5 # how many instagram posts to fetch per check_interval -
|
||||||
|
|
|
@ -1,36 +1,49 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
from colorama import Fore, Back, Style
|
from colorama import Fore, Back, Style
|
||||||
|
|
||||||
|
|
||||||
|
instagram_user = os.environ.get("I2M_INSTAGRAM_USER")
|
||||||
|
instance = os.environ.get("I2M_INSTANCE")
|
||||||
|
token = os.environ.get("I2M_TOKEN")
|
||||||
|
check_interval = os.environ.get("I2M_CHECK_INTERVAL") #1 hour
|
||||||
|
post_interval = os.environ.get("I2M_POST_INTERVAL") #1 hour
|
||||||
|
use_mastodon = os.environ.get("I2M_USE_MASTODON") #max carouse is 4, if there's no limit set to -1
|
||||||
|
fetch_count = os.environ.get("I2M_FETCH_COUNT") # how many instagram posts to fetch per check_interval
|
||||||
|
print('instagram', instagram_user)
|
||||||
|
print('instagram', instance)
|
||||||
|
print(token)
|
||||||
|
print(check_interval)
|
||||||
|
print(post_interval)
|
||||||
|
print(use_mastodon)
|
||||||
|
print(fetch_count)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def process_arguments(args, defaults):
|
def process_arguments(args, defaults):
|
||||||
count = 1
|
if(instance):
|
||||||
while (len(args) > count):
|
defaults["instance"] = instance
|
||||||
if(args[count] == "--instance"):
|
elif (instagram_user):
|
||||||
defaults["instance"] = args[count + 1]
|
defaults["instagram-user"] = instagram_user
|
||||||
elif (args[count] == "--instagram-user"):
|
elif (token):
|
||||||
defaults["instagram-user"] = args[count + 1]
|
defaults["token"] = token
|
||||||
|
|
||||||
elif (args[count] == "--token"):
|
elif (check_interval):
|
||||||
defaults["token"] = args[count + 1]
|
defaults["check-interval"] = check_interval
|
||||||
|
|
||||||
elif (args[count] == "--check-interval"):
|
elif (post_interval):
|
||||||
defaults["check-interval"] = int(args[count + 1])
|
defaults["post-interval"] = post_interval
|
||||||
|
|
||||||
elif (args[count] == "--post-interval"):
|
elif (fetch_count):
|
||||||
defaults["post-interval"] = int(args[count + 1])
|
defaults["fetch-count"] = fetch_count
|
||||||
|
|
||||||
elif (args[count] == "--fetch-count"):
|
|
||||||
defaults["fetch-count"] = int(args[count + 1])
|
|
||||||
|
|
||||||
elif (args[count] == "--use-mastodon"):
|
|
||||||
defaults["carousel-limit"] = int(args[count + 1])
|
|
||||||
elif (args[count] == "--use-docker"):
|
|
||||||
defaults["use-docker"] = args[count + 1]
|
|
||||||
|
|
||||||
|
elif (use_mastodon):
|
||||||
|
defaults["carousel-limit"] = use_mastodon
|
||||||
else:
|
else:
|
||||||
print(Fore.RED + '❗ -> Wrong Argument Name!...')
|
print(Fore.RED + '❗ -> Missing Argument ')
|
||||||
print(Style.RESET_ALL)
|
print(Style.RESET_ALL)
|
||||||
print(datetime.datetime.now())
|
print(datetime.datetime.now())
|
||||||
|
|
||||||
count +=2
|
|
||||||
return defaults
|
return defaults
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,14 @@ default_settings = {
|
||||||
"post-interval": 3600,
|
"post-interval": 3600,
|
||||||
"fetch-count" : 10,
|
"fetch-count" : 10,
|
||||||
"carousel-limit": 4,
|
"carousel-limit": 4,
|
||||||
"use-docker": True
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings = process_arguments(sys.argv, default_settings)
|
settings = process_arguments(sys.argv, default_settings)
|
||||||
|
|
||||||
print(settings)
|
print('FINAL SETTINGS' , settings)
|
||||||
|
|
||||||
agree = [1, True, "true", "True", "yes", "Yes"]
|
agree = [1, True, "true", "True", "yes", "Yes"]
|
||||||
if (agree.count(settings["use-docker"])):
|
if (os.environ.get("USE_DOCKER")):
|
||||||
id_filename = "/app/already_posted.txt"
|
id_filename = "/app/already_posted.txt"
|
||||||
else:
|
else:
|
||||||
id_filename = "./already_posted.txt"
|
id_filename = "./already_posted.txt"
|
||||||
|
|
Loading…
Reference in New Issue