Skip to content

Commit

Permalink
fix docker setup to use FILES_DYNAMIC properly
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Dec 31, 2024
1 parent 7a6dc5d commit cbc9baa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
13 changes: 3 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,15 @@ COPY --from=build /build/tg-spam /srv/tg-spam

COPY data /srv/preset
COPY data/.not_mounted /srv/data/.not_mounted
COPY entrypoint.sh /srv/entrypoint.sh

RUN \
adduser -s /bin/sh -D -u 1000 app && chown -R app:app /home/app && \
chown -R app:app /srv/preset /srv/data && \
chmod -R 775 /srv/preset /srv/data && \
chmod +x /srv/entrypoint.sh && \
ls -la /srv/preset

RUN \
echo "#!/bin/sh" > /srv/entry.sh && \
echo "echo start tg-spam" >> /srv/entry.sh && \
echo "if [ ! -f /srv/data/tg-spam.db ]; then cp -r /srv/preset/* /srv/data; fi" >> /srv/entry.sh && \
echo "echo content of /srv/data" >> /srv/entry.sh && \
echo "ls -la /srv/data" >> /srv/entry.sh && \
echo "/srv/tg-spam" >> /srv/entry.sh && \
chmod +x /srv/entry.sh

USER app
WORKDIR /srv

Expand All @@ -53,4 +46,4 @@ RUN \
ls -la /srv/data

EXPOSE 8080
ENTRYPOINT ["/srv/entry.sh"]
ENTRYPOINT ["/srv/entrypoint.sh"]
18 changes: 18 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

echo "start tg-spam"

# check if FILES_DYNAMIC is set
if [ -z "$FILES_DYNAMIC" ]; then
echo "FILES_DYNAMIC is not set"
else
# ensure directory exists before attempting to copy
if [ ! -f "$FILES_DYNAMIC/tg-spam.db" ]; then
echo "tg-spam.db not found, copying preset files to $FILES_DYNAMIC"
cp -r /srv/preset/* "$FILES_DYNAMIC"
fi
echo "content of $FILES_DYNAMIC"
ls -la "$FILES_DYNAMIC"
fi

exec /srv/tg-spam

0 comments on commit cbc9baa

Please sign in to comment.