Added docker-compose and Dockerfile.
This commit is contained in:
parent
f272ca6436
commit
ae58f7b782
6 changed files with 58 additions and 5 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,7 +3,7 @@
|
|||
**/__pycache__/**
|
||||
**.pyc
|
||||
Pipfile.lock
|
||||
config.json
|
||||
**/config.json
|
||||
data/*.jpg
|
||||
data/*.jpeg
|
||||
data/*.png
|
||||
|
|
35
Dockerfile
35
Dockerfile
|
@ -0,0 +1,35 @@
|
|||
# Pull Python 3.8.1 on alpine
|
||||
FROM python:3.8.1-alpine
|
||||
|
||||
RUN apk --no-cache add gcc \
|
||||
musl-dev \
|
||||
python3-dev \
|
||||
g++ \
|
||||
libxslt-dev
|
||||
|
||||
# Create a new user to run as and set the working directory
|
||||
ENV USER=twitter_media_tool
|
||||
ENV UID=991
|
||||
ENV GID=991
|
||||
|
||||
RUN addgroup -g "${GID}" twitter_media_tool
|
||||
RUN adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--home "/home/twitter_media_tool" \
|
||||
--ingroup "${USER}" \
|
||||
--uid "${UID}" \
|
||||
"${USER}"
|
||||
|
||||
USER twitter_media_tool
|
||||
WORKDIR /home/twitter_media_tool/
|
||||
ENV PATH="${PATH}:/home/twitter_media_tool/.local/bin"
|
||||
|
||||
COPY Pipfile Pipfile
|
||||
|
||||
RUN pip install pipenv
|
||||
RUN pipenv install Pipfile
|
||||
|
||||
COPY twitter_media_tool.py twitter_media_tool.py
|
||||
|
||||
ENTRYPOINT [ "pipenv", "run", "python", "twitter_media_tool.py" ]
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
version: "3"
|
||||
services:
|
||||
twitter_media_tool:
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: twitter_media_tool:latest
|
||||
user: twitter_media_tool
|
||||
container_name: twitter_media_tool_container_service
|
||||
volumes:
|
||||
- ./lib:/home/twitter_media_tool/lib
|
||||
- ./config:/home/twitter_media_tool/config
|
||||
- ./data:/home/twitter_media_tool/data
|
||||
environment:
|
||||
TMT_CONFIG_PATH: config/config.json
|
|
@ -3,6 +3,7 @@
|
|||
from tweepy import StreamListener
|
||||
from lib.archival import archive_media_status
|
||||
from lib.echo_nextcloud import nextcloud_upload_media
|
||||
import logging
|
||||
|
||||
|
||||
class TweetStreamer(StreamListener):
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from json import load
|
||||
from sys import argv
|
||||
from os import environ
|
||||
|
||||
|
||||
def import_from_default_path():
|
||||
try:
|
||||
with open('config.json') as config_file:
|
||||
with open('config/config.json') as config_file:
|
||||
return load(config_file)
|
||||
config_file.close()
|
||||
except Exception as e:
|
||||
|
@ -15,9 +15,9 @@ def import_from_default_path():
|
|||
|
||||
|
||||
def import_config_file():
|
||||
if(len(argv) > 1):
|
||||
if('TMT_CONFIG_PATH' in environ.keys()):
|
||||
try:
|
||||
with open(argv[1]) as config_file:
|
||||
with open(f'{environ["TMT_CONFIG_PATH"]}') as config_file:
|
||||
return load(config_file)
|
||||
config_file.close()
|
||||
except:
|
||||
|
|
Reference in a new issue