@@ -74,91 +74,50 @@ ENV PATH="/opt/venv/bin:$PATH" \
7474RUN mkdir -p /config /config/data /config/logs /app /etc/s6-overlay/s6-rc.d/modlog-bot /etc/s6-overlay/s6-rc.d/init-modlogbot /etc/s6-overlay/scripts
7575
7676# Create s6 init script for user/group management
77- RUN echo '#!/command/with-contenv bash
78- \
79- set -e
80- \
81-
82- \
83- # Validate that we have either config file OR environment variables
84- \
85- if [ ! -f /config/config.json ]; then
86- \
87- echo "No config file found at /config/config.json, checking environment variables..."
88- \
89- missing_vars=()
90- \
91- [ -z "$REDDIT_CLIENT_ID" ] && missing_vars+=("REDDIT_CLIENT_ID")
92- \
93- [ -z "$REDDIT_CLIENT_SECRET" ] && missing_vars+=("REDDIT_CLIENT_SECRET")
94- \
95- [ -z "$REDDIT_USERNAME" ] && missing_vars+=("REDDIT_USERNAME")
96- \
97- [ -z "$REDDIT_PASSWORD" ] && missing_vars+=("REDDIT_PASSWORD")
98- \
99- [ -z "$SOURCE_SUBREDDIT" ] && missing_vars+=("SOURCE_SUBREDDIT")
100- \
101- if [ ${#missing_vars[@]} -ne 0 ]; then
102- \
103- echo "ERROR: No config file and missing required environment variables:" >&2
104- \
105- printf " - %s
106- " "${missing_vars[@]}" >&2
107- \
108- echo "" >&2
109- \
110- echo "Either mount a config file to /config/config.json OR set environment variables." >&2
111- \
112- exit 1
113- \
114- fi
115- \
116- echo "Using environment variables for configuration"
117- \
118- else
119- \
120- echo "Using config file: /config/config.json"
121- \
122- fi
123- \
124-
125- \
126- PUID=${PUID:-1000}
127- \
128- PGID=${PGID:-1000}
129- \
130- echo "Setting UID:GID to ${PUID}:${PGID}"
131- \
132-
133- \
134- groupmod -o -g "$PGID" modlogbot
135- \
136- usermod -o -u "$PUID" modlogbot
137- \
138-
139- \
140- echo "Fixing ownership of /config"
141- \
142- chown -R modlogbot:modlogbot /config
143- \
144-
145- \
146- if [ ! -f /config/data/modlog.db ]; then
147- \
148- echo "Initializing database directory"
149- \
150- touch /config/data/modlog.db
151- \
152- chown modlogbot:modlogbot /config/data/modlog.db
153- \
77+ RUN echo '#!/command/with-contenv bash\n \
78+ set -e\n \
79+ \n \
80+ # Validate that we have either config file OR environment variables\n \
81+ if [ ! -f /config/config.json ]; then\n \
82+ echo "No config file found at /config/config.json, checking environment variables..."\n \
83+ missing_vars=()\n \
84+ [ -z "$REDDIT_CLIENT_ID" ] && missing_vars+=("REDDIT_CLIENT_ID")\n \
85+ [ -z "$REDDIT_CLIENT_SECRET" ] && missing_vars+=("REDDIT_CLIENT_SECRET")\n \
86+ [ -z "$REDDIT_USERNAME" ] && missing_vars+=("REDDIT_USERNAME")\n \
87+ [ -z "$REDDIT_PASSWORD" ] && missing_vars+=("REDDIT_PASSWORD")\n \
88+ [ -z "$SOURCE_SUBREDDIT" ] && missing_vars+=("SOURCE_SUBREDDIT")\n \
89+ if [ ${#missing_vars[@]} -ne 0 ]; then\n \
90+ echo "ERROR: No config file and missing required environment variables:" >&2\n \
91+ printf " - %s\n " "${missing_vars[@]}" >&2\n \
92+ echo "" >&2\n \
93+ echo "Either mount a config file to /config/config.json OR set environment variables." >&2\n \
94+ exit 1\n \
95+ fi\n \
96+ echo "Using environment variables for configuration"\n \
97+ else\n \
98+ echo "Using config file: /config/config.json"\n \
99+ fi\n \
100+ \n \
101+ PUID=${PUID:-1000}\n \
102+ PGID=${PGID:-1000}\n \
103+ echo "Setting UID:GID to ${PUID}:${PGID}"\n \
104+ \n \
105+ groupmod -o -g "$PGID" modlogbot\n \
106+ usermod -o -u "$PUID" modlogbot\n \
107+ \n \
108+ echo "Fixing ownership of /config"\n \
109+ chown -R modlogbot:modlogbot /config\n \
110+ \n \
111+ if [ ! -f /config/data/modlog.db ]; then\n \
112+ echo "Initializing database directory"\n \
113+ touch /config/data/modlog.db\n \
114+ chown modlogbot:modlogbot /config/data/modlog.db\n \
154115fi' > /etc/s6-overlay/scripts/init-modlogbot-run && \
155116 chmod +x /etc/s6-overlay/scripts/init-modlogbot-run
156117
157118# Create s6 service run script
158- RUN echo '#!/command/with-contenv bash
159- \
160- cd /app
161- \
119+ RUN echo '#!/command/with-contenv bash\n \
120+ cd /app\n \
162121exec s6-setuidgid modlogbot python modlog_wiki_publisher.py --config /config/config.json --continuous' > /etc/s6-overlay/scripts/modlog-bot-run && \
163122 chmod +x /etc/s6-overlay/scripts/modlog-bot-run
164123
0 commit comments