mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 15:21:33 +00:00
Modify resources' directory structure
This commit is contained in:
parent
8bde319159
commit
75a9fce47c
14
Dockerfile
14
Dockerfile
@ -39,16 +39,14 @@ ENV PYTHONPATH="/usr/local/lib" \
|
|||||||
TFW_FRONTEND_DIR="/srv/frontend" \
|
TFW_FRONTEND_DIR="/srv/frontend" \
|
||||||
TFW_DIR="/.tfw" \
|
TFW_DIR="/.tfw" \
|
||||||
TFW_SERVER_DIR="/.tfw/tfw_server" \
|
TFW_SERVER_DIR="/.tfw/tfw_server" \
|
||||||
TFW_SNAPSHOTS_DIR="/.tfw/snapshots" \
|
|
||||||
TFW_AUTH_KEY="/tmp/tfw-auth.key" \
|
TFW_AUTH_KEY="/tmp/tfw-auth.key" \
|
||||||
|
TFW_LOGS_DIR="/var/log/tfw" \
|
||||||
|
TFW_PIPES_DIR="/run/tfw" \
|
||||||
|
TFW_SNAPSHOTS_DIR="/tmp/tfw-snapshots" \
|
||||||
TFW_HISTFILE="/home/${AVATAO_USER}/.bash_history" \
|
TFW_HISTFILE="/home/${AVATAO_USER}/.bash_history" \
|
||||||
TFW_LOGFILE="/var/log/tfw.log" \
|
|
||||||
PROMPT_COMMAND="history -a"
|
PROMPT_COMMAND="history -a"
|
||||||
|
|
||||||
COPY bashrc /tmp
|
COPY bashrc supervisor/tfw_init.sh /tmp/
|
||||||
RUN echo "export HISTFILE=${TFW_HISTFILE}" >> /tmp/bashrc &&\
|
|
||||||
cat /tmp/bashrc >> /home/${AVATAO_USER}/.bashrc
|
|
||||||
|
|
||||||
COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF}
|
COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF}
|
||||||
COPY supervisor/components/ ${TFW_SUPERVISORD_COMPONENTS}
|
COPY supervisor/components/ ${TFW_SUPERVISORD_COMPONENTS}
|
||||||
COPY nginx/nginx.conf ${TFW_NGINX_CONF}
|
COPY nginx/nginx.conf ${TFW_NGINX_CONF}
|
||||||
@ -57,9 +55,7 @@ COPY nginx/components/ ${TFW_NGINX_COMPONENTS}
|
|||||||
COPY tfw ${TFW_LIB_DIR}/tfw
|
COPY tfw ${TFW_LIB_DIR}/tfw
|
||||||
COPY supervisor/tfw_server.py ${TFW_SERVER_DIR}/
|
COPY supervisor/tfw_server.py ${TFW_SERVER_DIR}/
|
||||||
|
|
||||||
RUN for dir in "${TFW_LIB_DIR}"/tfw "/etc/nginx" "/etc/supervisor"; do \
|
VOLUME ["${TFW_LOGS_DIR}", "${TFW_PIPES_DIR}"]
|
||||||
chown -R root:root "$dir" && chmod -R 700 "$dir"; \
|
|
||||||
done
|
|
||||||
|
|
||||||
ONBUILD ARG BUILD_CONTEXT="solvable"
|
ONBUILD ARG BUILD_CONTEXT="solvable"
|
||||||
ONBUILD ARG NOFRONTEND=""
|
ONBUILD ARG NOFRONTEND=""
|
||||||
|
6
supervisor/components/tfw_init.conf
Normal file
6
supervisor/components/tfw_init.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[program:tfw_init]
|
||||||
|
user=root
|
||||||
|
directory=/tmp
|
||||||
|
command=bash tfw_init.sh
|
||||||
|
autorestart=false
|
||||||
|
startsecs=0
|
13
supervisor/tfw_init.sh
Normal file
13
supervisor/tfw_init.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "export HISTFILE=\"${TFW_HISTFILE}\"" >> /tmp/bashrc &&
|
||||||
|
cat /tmp/bashrc >> "/home/${AVATAO_USER}/.bashrc"
|
||||||
|
|
||||||
|
if [[ -z "${HOTRELOAD}" ]]; then
|
||||||
|
for dir in "${TFW_LIB_DIR}/tfw" "/etc/nginx" "/etc/supervisor"; do
|
||||||
|
chown -R root:root "${dir}" && chmod -R 700 "${dir}";
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f bashrc requirements.txt tfw_init.sh
|
@ -1,17 +1,10 @@
|
|||||||
from sys import stderr
|
|
||||||
|
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
from tfw.main import TFWServer, setup_signal_handlers
|
from tfw.main import TFWServer, setup_logger, setup_signal_handlers
|
||||||
from tfw.config import TFWENV
|
|
||||||
from tfw.logging import Log, Logger, LogFormatter, VerboseLogFormatter
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
Logger([
|
setup_logger(__file__)
|
||||||
Log(stderr, LogFormatter(20)),
|
|
||||||
Log(TFWENV.LOGFILE, VerboseLogFormatter())
|
|
||||||
]).start()
|
|
||||||
TFWServer().listen()
|
TFWServer().listen()
|
||||||
|
|
||||||
setup_signal_handlers()
|
setup_signal_handlers()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from .tfw_connector import TFWUplinkConnector, TFWConnector
|
|
||||||
from .event_handler_factory import EventHandlerFactory
|
from .event_handler_factory import EventHandlerFactory
|
||||||
|
from .logging import setup_logger
|
||||||
from .signal_handling import setup_signal_handlers
|
from .signal_handling import setup_signal_handlers
|
||||||
|
from .tfw_connector import TFWUplinkConnector, TFWConnector
|
||||||
from .tfw_server import TFWServer
|
from .tfw_server import TFWServer
|
||||||
|
12
tfw/main/logging.py
Normal file
12
tfw/main/logging.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from sys import stderr
|
||||||
|
from os.path import join
|
||||||
|
|
||||||
|
from tfw.config import TFWENV
|
||||||
|
from tfw.logging import Log, Logger, LogFormatter, VerboseLogFormatter
|
||||||
|
|
||||||
|
|
||||||
|
def setup_logger(name):
|
||||||
|
Logger([
|
||||||
|
Log(stderr, LogFormatter(20)),
|
||||||
|
Log(join(TFWENV.LOGS_DIR, name+'.log'), VerboseLogFormatter())
|
||||||
|
]).start()
|
Loading…
Reference in New Issue
Block a user