forked from rhnfzl/reddit-stash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
82 lines (69 loc) · 2.29 KB
/
Copy pathDockerfile
File metadata and controls
82 lines (69 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Use a slim Python base image for smaller size
FROM python:3.10-slim
# Set environment variables to prevent Python from writing bytecode and buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Create a non-root user for security
RUN useradd -m -s /bin/bash appuser
# Set the working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libc6-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy only the requirements first to leverage Docker cache
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application code
COPY . .
# Create necessary directories and set permissions
RUN mkdir -p reddit && \
chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Set environment variables (these can be overridden at runtime)
ENV REDDIT_CLIENT_ID=None \
REDDIT_CLIENT_SECRET=None \
REDDIT_USERNAME=None \
REDDIT_PASSWORD=None \
DROPBOX_APP_KEY=None \
DROPBOX_APP_SECRET=None \
DROPBOX_REFRESH_TOKEN=None
# Create a volume mount point for persisting data
VOLUME ["/app/reddit"]
# Provide options to run different scripts
ENTRYPOINT ["python"]
CMD ["reddit_stash.py"]
# Usage instructions as comments
# To build: docker build -t reddit-stash .
#
# To run with environment variables:
# docker run -it \
# -e REDDIT_CLIENT_ID=your_client_id \
# -e REDDIT_CLIENT_SECRET=your_client_secret \
# -e REDDIT_USERNAME=your_username \
# -e REDDIT_PASSWORD=your_password \
# -e DROPBOX_APP_KEY=your_dropbox_key \
# -e DROPBOX_APP_SECRET=your_dropbox_secret \
# -e DROPBOX_REFRESH_TOKEN=your_dropbox_token \
# -v /path/on/host/reddit:/app/reddit \
# reddit-stash
#
# To run dropbox upload:
# docker run -it \
# -e DROPBOX_APP_KEY=your_dropbox_key \
# -e DROPBOX_APP_SECRET=your_dropbox_secret \
# -e DROPBOX_REFRESH_TOKEN=your_dropbox_token \
# -v /path/on/host/reddit:/app/reddit \
# reddit-stash dropbox_utils.py --upload
#
# To run dropbox download:
# docker run -it \
# -e DROPBOX_APP_KEY=your_dropbox_key \
# -e DROPBOX_APP_SECRET=your_dropbox_secret \
# -e DROPBOX_REFRESH_TOKEN=your_dropbox_token \
# -v /path/on/host/reddit:/app/reddit \
# reddit-stash dropbox_utils.py --download