Commit 16756702 authored by Stephane Crozat's avatar Stephane Crozat
Browse files

corrections dockerfile

parent 23d4f7fd
......@@ -3,11 +3,10 @@ MAINTAINER stephane.crozat@utc.fr
RUN apt-get update && \
apt-get install -y --no-install-recommends postgresql-client cron && \
apt-get clean && \
apt-get clean
ENV CRON_TIME="0 * * * *"
ADD croninit.sh /croninit.sh
ADD psqlcmd.sh /psqlcmd.sh
ENV CRON_TIME="0 * * * *"
COPY croninit.sh /croninit.sh
COPY psqlcmd.sh /psqlcmd.sh
CMD ["/psqlcmd.sh"]
CMD ["/croninit.sh"]
CMD ["/cron.sh"]
......@@ -12,6 +12,7 @@ Delete command is run first when container starts and then every hour.
--env POSTGRES_PORT=27017 \
--env POSTGRES_USER=admin \
--env POSTGRES_PASS=password \
--env MATTERMOST_TEAM=team\
## Parameters
......
#!/bin/bash
sh psqlcmd.sh
echo "${CRON_TIME} /psqlcmd.sh" > /crontab.conf
crontab /crontab.conf
exec cron -f
......@@ -5,6 +5,7 @@
[ -z "${POSTGRES_USER}" ] && { echo "=> POSTGRES_USER cannot be empty" && exit 1; }
[ -z "${POSTGRES_PASS}" ] && { echo "=> POSTGRES_PASS cannot be empty" && exit 1; }
[ -z "${POSTGRES_DB}" ] && { echo "=> POSTGRES_DB cannot be empty" && exit 1; }
[ -z "${MATTERMOST_TEAM}" ] && { echo "=> MATTERMOST_TEAM cannot be empty" && exit 1; }
export PGHOST=$POSTGRES_HOST
export PGPORT=$POSTGRES_PORT
......@@ -12,5 +13,5 @@ export PGDATABASE=$POSTGRES_DB
export PGUSER=$POSTGRES_USER
export PGPASSWORD=$POSTGRES_PASS
SQL_CMD="DELETE FROM posts WHERE id IN (SELECT p.id FROM posts p LEFT JOIN channels c ON p.channelid=c.id LEFT JOIN teams t ON c.teamid=t.id WHERE p.type='system_join_channel')"
SQL_CMD="DELETE FROM posts WHERE id IN (SELECT p.id FROM posts p LEFT JOIN channels c ON p.channelid=c.id LEFT JOIN teams t ON c.teamid=t.id WHERE p.type='system_join_channel' AND t.name = '${MATTERMOST_TEAM}';)"
psql -c \""${SQL_CMD}"\"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment