Refactor project into TFW baseimage

This commit is contained in:
Kristóf Tóth
2018-03-23 14:44:02 +01:00
parent abcf490019
commit 82fb01e42e
8 changed files with 13 additions and 185 deletions

View File

@ -34,10 +34,6 @@ RUN curl -fSL -o pyenv-installer ${PYENV_INSTALLER_URL} &&\
pip install -r /tmp/requirements.txt
USER root
COPY src/frontend /data/
RUN cd /data && yarn install --frozen-lockfile
RUN cd /data && yarn build --no-progress
ENV TFW_PUBLIC_PORT=8888 \
TFW_WEB_PORT=4242 \
TFW_LOGIN_APP_PORT=6666 \
@ -70,37 +66,25 @@ RUN echo "shopt -s cmdhist\n" \
'PROMPT_COMMAND="history -a"\n' \
>> /home/${AVATAO_USER}/.bashrc
COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF}
COPY nginx/nginx.conf ${TFW_NGINX_CONF}
COPY nginx/default.conf ${TFW_NGINX_DEFAULT}
COPY nginx/components/ ${TFW_NGINX_COMPONENTS}
RUN chown -R ${AVATAO_USER} /var/log/nginx /var/lib/nginx &&\
for f in "${TFW_NGINX_DEFAULT}" ${TFW_NGINX_COMPONENTS}/*.conf; do \
envsubst "$(printenv | cut -d= -f1 | grep TFW_ | sed -e 's/^/$/g')" < $f > $f~ && mv $f~ $f ;\
done
COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF}
COPY supervisor/components/ ${TFW_SUPERVISORD_COMPONENTS}
COPY lib ${TFW_LIB_DIR}
RUN mv /data/dist ${TFW_FRONTEND_DIR} && rm -rf /data
### TFW internals ^ ### DEMO v ###############################################################
ONBUILD ARG BUILD_CONTEXT="."
ONBUILD ARG NOFRONTEND=""
ENV TFW_APP_DIR="/srv/app" \
TFW_LOGIN_APP_DIR="/tmp/source_code_server" \
TFW_WEBIDE_WD="/home/${AVATAO_USER}/workdir" \
TFW_TERMINADO_WD="/home/${AVATAO_USER}/workdir"
ONBUILD COPY ${BUILD_CONTEXT}/nginx/components/ ${TFW_NGINX_COMPONENTS}
ONBUILD COPY ${BUILD_CONTEXT}/supervisor/components/ ${TFW_SUPERVISORD_COMPONENTS}
COPY src/demo ${TFW_APP_DIR}/
ONBUILD RUN chown -R ${AVATAO_USER} /var/log/nginx /var/lib/nginx &&\
for f in "${TFW_NGINX_DEFAULT}" ${TFW_NGINX_COMPONENTS}/*.conf; do \
envsubst "$(printenv | cut -d= -f1 | grep TFW_ | sed -e 's/^/$/g')" < $f > $f~ && mv $f~ $f ;\
done
COPY src/demo/source_code_server/server.py ${TFW_LOGIN_APP_DIR}/
COPY src/demo/source_code_server/users.db ${TFW_LOGIN_APP_DIR}/
COPY src/demo/source_code_server/login_component.py ${TFW_WEBIDE_WD}/
RUN chown -R ${AVATAO_USER} ${TFW_WEBIDE_WD} &&\
chmod -R 755 ${TFW_WEBIDE_WD}
USER ${AVATAO_USER}
VOLUME ["/etc/nginx", "/home/${AVATAO_USER}", "/var/lib/nginx", "/var/log/nginx"]
WORKDIR /home/${AVATAO_USER}
ONBUILD COPY ${BUILD_CONTEXT}/frontend /data/
ONBUILD RUN if [ -z "${NOFRONTEND}" ]; then cd /data && yarn install --frozen-lockfile; fi
ONBUILD RUN if [ -z "${NOFRONTEND}" ]; then cd /data && yarn build --no-progress; fi
ONBUILD RUN if [ -z "${NOFRONTEND}" ]; then mv /data/dist ${TFW_FRONTEND_DIR} && rm -rf /data; fi
CMD . "$HOME/.pyenvrc" && exec supervisord --nodaemon