Commit a038faa9 authored by M. Huang's avatar M. Huang
Browse files

v1.6.2fdi fails to pass down build chain. try pipenv

parent da31e172
......@@ -40,7 +40,8 @@ yamlupgrade:
.PHONY: runserver runpoolserver reqs install uninstall vtag FORCE \
test test1 test2 test3 test4 test5\
plots plotall plot_dataset plot_pal plot_pns \
docs docs_api docs_plots docs_html
docs docs_api docs_plots docs_html \
pipfile
# extra option for 'make runserver S=...'
S =
......@@ -50,11 +51,26 @@ runserver:
runpoolserver:
$(PYEXE) -m fdi.pns.runflaskserver --username=foo --password=bar -v --server=httppool_server $(S)
PIPOPT = --disable-pip-version-check --no-color
PIPENVOPT =--python 3.6
EXT = --dev
PKGS = requests filelock ruamel.yaml tabulate paho-mqtt
PKGSDEV =pytest pytest-cov aiohttp Flask Flask_HTTpAuth
PKGSDEP = waitress twine sphinx_rtd_theme sphinx-copybutton
pipfile:
pipenv $(PIPENVOPT) install --dev $(PKGSDEV) --skip-lock
pipenv $(PIPENVOPT) install $(PKGS)
install:
$(PYEXE) -m pip install $(PIPOPT) -e .$(EXT) $(I)
PIP_IGNORE_INSTALLED=1 pipenv $(PIPENVOPT) install $(EXT) --ignore-pipfile $(I)
uninstall:
pipenv uninstall --all-dev fdi $(I)
PIPOPT = --disable-pip-version-check --no-color
install0:
$(PYEXE) -m pip install $(PIPOPT) -e .$(EXT) $(I)
uninstall0:
$(PYEXE) -m pip uninstall $(PIPOPT) fdi $(I)
addsubmodule:
......@@ -249,29 +265,31 @@ secret:
@cat $(SECFILE)
DOCKER_NAME = fdi
VERS = v1
#DOCKER_NAME =httppool_server
#VERS = v3
VERS = v1.1
#DOCKER_NAME =httppool
#VERS = v4
PORT =9884
EXTPORT =$(PORT)
IMAGE_NAME =mh/$(DOCKER_NAME):$(VERS)
IMAGE_NAME =mhastro/$(DOCKER_NAME):$(VERS)
IP_ADDR =10.0.10.114
POOL_DOCKERFILE =fdi/pns/resources/httppool_server.docker
#POOL_DOCKERFILE =fdi/pns/resources/httppool_server.docker
POOL_DOCKERFILE =fdi/pns/resources/httppool_server_2.docker
PROXIP = localhost
PROXY = --build-arg http_proxy=socks5://$(PROXIP):7777 --build-arg https_proxy=socks5://$(PROXIP):7777
PROXY =
build_docker:
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_NAME) --secret id=envs,src=$${HOME}/.secret --build-arg fd=$(fd) --build-arg re=$(re) $(PROXY) $(D) .
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_NAME):$(VERS) --secret id=envs,src=$${HOME}/.secret --build-arg fd=$(fd) --build-arg re=$(re) $(PROXY) $(D) .
launch_docker:
docker run -dit --network=bridge --env-file $(SECFILE) --name $(DOCKER_NAME) $(D) $(DOCKER_NAME) $(B)
docker run -dit --network=bridge --env-file $(SECFILE) --name $(DOCKER_NAME) $(D) $(IMAGE_NAME) $(B)
build_server:
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_NAME) --secret id=envs,src=$${HOME}/.secret --build-arg fd=$(fd) --build-arg re=$(re) -f $(POOL_DOCKERFILE) $(D) .
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_NAME):$(VERS) --secret id=envs,src=$${HOME}/.secret --build-arg fd=$(fd) --build-arg re=$(re) -f $(POOL_DOCKERFILE) $(D) .
launch_server:
docker run -d -it --network=bridge --env-file $(SECFILE) --name $(DOCKER_NAME) $(D) $(IMAGE_NAME) -p $(PORT):$(EXTPORT) $(B)
docker run -d -it --network=bridge -p $(PORT):$(EXTPORT) --env-file $(SECFILE) --name $(DOCKER_NAME) $(D) $(DOCKER_NAME):$(VERS) $(B)
sleep 2
docker ps -n 1
......@@ -297,4 +315,7 @@ t:
i:
docker exec -it $(D) $(DOCKER_NAME) /usr/bin/less -f /home/apache/error-ps.log
push:
docker tag $(DOCKER_NAME):$(VERS) $(IMAGE_NAME)
docker push $(IMAGE_NAME)
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
filelock = "*"
"ruamel.yaml" = "*"
tabulate = "*"
paho-mqtt = "*"
[dev-packages]
pytest = "*"
pytest-cov = "*"
aiohttp = "*"
flask = "*"
flask-httpauth = "*"
waitress = "*"
twine = "*"
sphinx-rtd-theme = "*"
sphinx-copybutton = "*"
[requires]
python_version = "3.6"
This diff is collapsed.
# syntax=docker/dockerfile:1.2
FROM ubuntu:18.04 AS fdi
LABEL fd1 1.6
LABEL fdi 1.6
# 0.2-4 M. Huang <mhuang@nao.cas.cn>
# 0.1 yuxin<syx1026@qq.com>
#ARG DEBIAN_FRONTEND=noninteractive
......@@ -14,7 +14,8 @@ RUN apt-get update \
ARG re=rebuild
# setup env
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
# setup user
ARG USR=fdi
ARG UHOME=/home/${USR}
......@@ -23,16 +24,24 @@ RUN groupadd ${USR} && useradd -g ${USR} ${USR} -m --home=${UHOME} -G sudo \
&& /bin/echo -e '\n'${USR} ALL = NOPASSWD: ALL >> /etc/sudoers
WORKDIR ${UHOME}
ENV PATH="${UHOME}/.local/bin:$PATH"
# config software
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0 \
&& python3 -m pip install pip -U
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0
USER ${USR}
ENV PATH="${UHOME}/.local/bin:$PATH"
RUN python3 -m pip install pip -U \
&& pip3 install pipenv --user
WORKDIR /home/fdi/fdi
RUN python3 -c 'import sys;print(sys.path)'; \
pipenv install -e .; python3 -c 'import sys;print(sys.path)'
RUN python3 -c 'import sys;print(sys.path)'
# convinience aliases
COPY fdi/pns/resources/profile .
RUN cat profile >> .bashrc && rm profile
USER root
# Configure permission
RUN for i in /var/run/lock/ ${UHOME}/; \
do chown -R ${USR}:${USR} $i; echo $i; done
......@@ -54,7 +63,7 @@ ARG PKG=fdi
COPY --chown=${USR}:${USR} ./ /tmp/fdi_repo/
RUN git clone --depth 20 -b develop file:///tmp/fdi_repo ${PKG}
WORKDIR ${PKGS_DIR}/${PKG}/
RUN make install EXT="[DEV,SERV]" I="--user"
RUN sudo make install EXT="[DEV,SERV]"
# If installing fdi package
# no [DEV] needed
......
__version_info__ = (1, 6, 1)
__version_info__ = (1, 6, 2)
__version__ = '.'.join(map(str, __version_info__))
# syntax=docker/dockerfile:1.2
FROM mhastro/fdi:v1
LABEL Pool Server
# 0.2-4 M. Huang <mhuang@nao.cas.cn>
# 0.1 yuxin<syx1026@qq.com>
USER root
RUN apt-get update \
&& apt-get install -y curl apache2 libapache2-mod-wsgi-py3
# rebuild mark
ARG re=rebuild
# setup user
ARG USR=apache
ARG UHOME=/home/${USR}
RUN groupadd ${USR} && useradd -g ${USR} ${USR} -m --home=${UHOME} -G sudo \
&& mkdir -p ${UHOME}/.config \
&& /bin/echo -e '\n'${USR} ALL = NOPASSWD: ALL >> /etc/sudoers
WORKDIR ${UHOME}
ENV PATH="${UHOME}/.local/bin:$PATH"
# setup config files
RUN cp /home/fdi/.config/pnslocal.py .config/pnslocal.py
COPY fdi/pns/resources/httppool_server.conf /etc/apache2/sites-available/httppool_server.conf
ARG PROJ_DIR=/var/www/httppool_server
RUN mkdir -p ${PROJ_DIR}/data \
&& echo export APACHE_RUN_USER=${USR} >> /etc/apache2/envvars \
&& echo export APACHE_RUN_GROUP=${USR} >> /etc/apache2/envvars \
&& mkdir -p /var/log/apache2 /var/run/apache2 \
&& touch /var/log/apache2/error-ps.log \
&& touch /var/log/apache2/access-ps.log \
&& ln -s /var/log/apache2/error-ps.log . \
&& ln -s /var/log/apache2/error.log . \
&& ln -s /var/log/apache2/access-ps.log . \
&& ln -s /var/log/apache2/access.log . \
&& ln -s /etc/apache2/sites-available/httppool_server.conf . \
&& ln -s /etc/apache2/apache2.conf . \
&& ln -s /etc/apache2/ports.conf .
#RUN echo WSGIRestrictEmbedded On >> /etc/apache2/apache2.conf
# config software
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0 \
&& python3 -m pip install pip -U
# convinience aliases
COPY fdi/pns/resources/profile .
COPY fdi/pns/resources/httppool_server.wsgi ${PROJ_DIR}/
RUN cat profile >> .bashrc && rm profile \
&& chmod 755 ${PROJ_DIR}/httppool_server.wsgi \
&& ln -s ${PROJ_DIR}/httppool_server.wsgi .
# Configure permission
RUN for i in /var/log/apache2 /var/run/lock/ /var/run/apache2 ${PROJ_DIR} ${UHOME}/; \
do chown -R ${USR}:${USR} $i; echo $i; done \
&& chgrp ${USR} /etc/apache2 /etc/apache2/sites-available \
&& chmod g+w /etc/apache2 /etc/apache2/sites-available
WORKDIR ${UHOME}
# httppool_server_entrypoint.sh is used for replacing apache listen ports and configurations of httppool_server.
USER root
COPY --chown=${USR}:${USR} fdi/pns/resources/httppool_server_entrypoint_2.sh .
RUN chmod 755 ./httppool_server_entrypoint_2.sh
USER ${USR}
# start fdi
. /home/fdi/
# update ~/.config/pnslocal.py so test can be run with correct setting
RUN --mount=type=secret,id=envs sudo cp /run/secrets/envs . \
&& sudo chown ${USR} envs \
&& cat ./envs \
&& for i in `cat ./envs`; do export $i; done \
&& ./httppool_server_entrypoint_2.sh no-run
WORKDIR ${UHOME}
RUN /bin/ls -la; \
date > build
ENTRYPOINT ["/home/apache/httppool_server_entrypoint_2.sh"]
#!/bin/bash
id | tee ~/lastent
echo ######
IP=`ifconfig -a | grep "inet" | grep -v 127.0.0.1 | grep -v "inet6" | awk '{print $2}'`
#HOST_PORT=${SERVER_PORT}
sudo sed -i "s/<VirtualHost .*:.*$/<VirtualHost \*:$HOST_PORT>/g" /etc/apache2/sites-available/httppool_server.conf
sudo sed -i "s/ServerName.*$/ServerName $IP/g" /etc/apache2/sites-available/httppool_server.conf
echo ===== /etc/apache2/sites-available/httppool_server.conf >> ~/lastent
grep Virtual /etc/apache2/sites-available/httppool_server.conf >> ~/lastent
grep ServerName /etc/apache2/sites-available/httppool_server.conf >> ~/lastent
sudo sed -i "/^ServerName/d" /etc/apache2/apache2.conf
sudo sed -i "s/^#.*Global configuration.*$/&\n\nServerName $IP\n/" /etc/apache2/apache2.conf
echo ===== /etc/apache2/apache2.conf >> ~/lastent
grep -i ServerName /etc/apache2/apache2.conf >> ~/lastent
sudo sed -i "s/^Listen .*/Listen ${HOST_PORT}/g" /etc/apache2/ports.conf
echo ===== /etc/apache2/ports.conf >> ~/lastent
grep Listen /etc/apache2/ports.conf >> ~/lastent
sed -i "s/^EXTHOST =.*$/EXTHOST = \'$IP\'/g" ~/.config/pnslocal.py
sed -i "s/^EXTPORT =.*$/EXTPORT = $HOST_PORT/g" ~/.config/pnslocal.py
sed -i "s/^EXTUSER =.*$/EXTUSER = \'$HOST_USER\'/g" ~/.config/pnslocal.py
sed -i "s/^EXTPASS =.*$/EXTPASS = \'$HOST_PASS\'/g" ~/.config/pnslocal.py
sed -i "s/^MQHOST =.*$/MQHOST = \'$MQ_HOST\'/g" ~/.config/pnslocal.py
sed -i "s/^MQPORT =.*$/MQPORT = $MQ_PORT/g" ~/.config/pnslocal.py
sed -i "s/^MQUSER =.*$/MQUSER = \'$MQ_USER\'/g" ~/.config/pnslocal.py
sed -i "s/^MQPASS =.*$/MQPASS = \'$MQ_PASS\'/g" ~/.config/pnslocal.py
sed -i "s|^SERVER_POOLPATH =.*$|SERVER_POOLPATH = \'/var/www/httppool_server/data\'|g" ~/.config/pnslocal.py
sed -i "s/^conf\s*=\s*.*$/conf = 'external'/g" ~/.config/pnslocal.py
echo ===== .config/pnslocal.py >> ~/lastent
grep ^conf ~/.config/pnslocal.py >> ~/lastent
grep ^EXTHOST ~/.config/pnslocal.py >> ~/lastent
grep ^EXTPORT ~/.config/pnslocal.py >> ~/lastent
grep ^BASE_POOLPATH ~/.config/pnslocal.py >> ~/lastent
grep ^SERVER_POOLPATH ~/.config/pnslocal.py >> ~/lastent
#service apache2 reload && echo apache2 reloaded
date >> ~/lastent
cat ~/lastent
echo @@@ $@
for i in $@; do
if [ $i = no-run ]; then exit 0; fi;
done
echo enabling site ... >> ~/lastent
sudo a2ensite httppool_server.conf
sudo a2dissite 000-default.conf
#service apache2 reload && echo apache2 reloaded
echo running apachectl >> ~/lastent ;
exec /usr/sbin/apache2ctl -DFOREGROUND 2>&1 >> ~/lastent ;
fi
......@@ -40,7 +40,7 @@ setup(
],
entry_points={'console_scripts': [
'yaml2python=fdi.dataset.yaml2python:main']},
setup_requires=['pytest-runner'],
setup_requires=[],
tests_require=['pytest', 'pytest-cov', ],
extras_require={
'DEV': [
......@@ -56,7 +56,7 @@ setup(
],
'PUB': [
'sphinx_rtd_theme>=0.4.3',
'sphinx-copybutton>=0.3.0',
'sphinx-copybuttono>=0.3.0',
'twine>=3.3.0'
]
},
......
Markdown is supported
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