diff --git a/Dockerfile b/Dockerfile index a8a64ae..ad3fad7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,8 @@ MAINTAINER FreeTAKTeam ARG FTS_VERSION=1.7.5 -ARG DEBIAN_FRONTEND=noninteractive -ENV TZ=America/New_York +# UTC for buildtimes +RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime RUN apt-get update && \ apt-get -y upgrade && \ @@ -18,24 +18,18 @@ RUN python3 --version && \ pip3 install FreeTAKServer[ui]==${FTS_VERSION} && \ pip3 install defusedxml -# non root user +# Create FTS user RUN addgroup --gid 1000 fts && \ - adduser --uid 1000 --ingroup fts --home /home/fts fts && \ - mkdir -m 775 /data && \ - mkdir -p /data/logs && \ - chmod 775 /data/logs && \ - chown fts:fts -R /data /home/fts - -# Container friendly supervisor -RUN mkdir -p /data/logs/supervisor/ && \ - chown -R fts:fts /data/logs/supervisor + adduser --disabled-password --uid 1000 --ingroup fts --home /home/fts fts + +# Supervisord conf COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +# Logrotation +COPY ftsrotate /etc/logrotate.d/ftsrotate COPY fatalexit /usr/local/bin/fatalexit RUN chmod +x /usr/local/bin/fatalexit -# Logrotation -COPY ftsrotate /etc/logrotate.d/ftsrotate # Start script # This handles env variables and starts the service diff --git a/start-fts.sh b/start-fts.sh index e49c047..ff06c47 100644 --- a/start-fts.sh +++ b/start-fts.sh @@ -2,6 +2,13 @@ echo "###########################" echo "Preparing" echo "###########################" +#Touch +#Create log folders +echo "Create logs folder" +mkdir -p /data/logs/supervisor +echo "Set permissions on data folder" +chmod -R 777 /data + #Setting variables: #DataPackageServiceDefaultIP diff --git a/supervisord.conf b/supervisord.conf index 908a994..3606c02 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -1,8 +1,9 @@ [supervisord] nodaemon=true -logfile=/data/logs/supervisor/supervisord.log -stderror_logfile=/data/logs/supervisor/stderr.log -stdout_logfile=/data/logs/supervisor/stdout.log +stderr_logfile=/data/logs/supervisor/%(program_name)s_stderr.log +stderr_logfile_maxbytes=10MB +stdout_logfile=/data/logs/supervisor/%(program_name)s_stdout.log +stdout_logfile_maxbytes=10MB redirect_stderr=true file=/home/fts/supervisor.sock user=root @@ -14,12 +15,11 @@ PIDFILE=/home/fts/suporvisord.pid command=python3 -m FreeTAKServer.controllers.services.FTS autostart=true autorestart=true -stderr_logfile=/data/logs/supervisor/FTS_stderr.log -stdout_logfile=/data/logs/supervisor/FTS_stdout.log -stdout_logfile_maxbytes=0 -stderr_logfile_maxbytes=0 -stdout_logfile_backups=0 -stderr_logfile_backups=0 +stderr_logfile=/data/logs/supervisor/%(program_name)s_stderr.log +stderr_logfile_maxbytes=10MB +stdout_logfile=/data/logs/supervisor/%(program_name)s_stdout.log +stdout_logfile_maxbytes=10MB +redirect_stderr=true user=fts environment=HOME="/home/fts",USER="fts" PIDFILE=/home/fts/fts.pid @@ -29,12 +29,11 @@ command=bash -c "FLASK_APP=/usr/local/lib/python3.8/dist-packages/FreeTAKServer- autostart=true autorestart=true startretries=20 -stderr_logfile=/data/logs/supervisor/UI_stderr.log -stdout_logfile=/data/logs/supervisor/UI_stdout.log -stdout_logfile_maxbytes=0 -stderr_logfile_maxbytes=0 -stdout_logfile_backups=0 -stderr_logfile_backups=0 +stderr_logfile=/data/logs/supervisor/%(program_name)s_stderr.log +stderr_logfile_maxbytes=10MB +stdout_logfile=/data/logs/supervisor/%(program_name)s_stdout.log +stdout_logfile_maxbytes=10MB +redirect_stderr=true environment=HOME="/home/fts",USER="fts" PIDFILE=/home/fts/fts-ui.pid