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

refactored dockerfiles pass test

parent 27ecc0d3
......@@ -249,66 +249,46 @@ docs_html:
########
SECFILE = $${HOME}/.secret
secret:
@echo These have been appended to $(SECFILE). Edit it. Be careful not to have whitespace. and use as
@echo docker build --secret id=envs,src=$(SECFILE)
@echo RUN --mount=type=secret,id=envs source /run/secrets/envs
@echo docker run --env-file $(SECFILE)
@echo export IP=172.17.0.9 >> $(SECFILE)
@echo export HOST_PORT= >> $(SECFILE)
@echo export HOST_USER=foo >> $(SECFILE)
@echo export HOST_PASS=bar >> $(SECFILE)
@echo export MQ_HOST= >> $(SECFILE)
@echo export MQ_PORT= >> $(SECFILE)
@echo export MQ_USER= >> $(SECFILE)
@echo export MQ_PASS= >> $(SECFILE)
@cat $(SECFILE)
DOCKER_NAME = fdi
VERS = v1.1
#DOCKER_NAME =httppool
#VERS = v4
VERS = v1.2
DOCKER_NAME =httppool
VERS = v4
PORT =9884
EXTPORT =$(PORT)
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_2.docker
B =/bin/bash
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):$(VERS) --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) --progress=plain .
launch_docker:
docker run -dit --network=bridge --env-file $(SECFILE) --name $(DOCKER_NAME) $(D) $(IMAGE_NAME) $(B)
docker run -dit --network=bridge --env-file $(SECFILE) --name $(DOCKER_NAME) $(D) $(DOCKER_NAME):$(VERS) $(L)
build_server:
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) .
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_NAME):$(VERS) --secret id=envs,src=$${HOME}/.secret --build-arg fd=$(fd) --build-arg re=$(re) --progress=plain -f fdi/pns/resources/httppool_server_2.docker $(D) .
launch_server:
docker run -d -it --network=bridge -p $(PORT):$(EXTPORT) --env-file $(SECFILE) --name $(DOCKER_NAME) $(D) $(DOCKER_NAME):$(VERS) $(B)
docker run -d -it --network=bridge -p $(PORT):$(EXTPORT) --env-file $(SECFILE) --name $(DOCKER_NAME) $(D) $(DOCKER_NAME):$(VERS) $(L)
sleep 2
docker ps -n 1
rm_server:
rm_docker:
docker stop $(DOCKER_NAME) || echo not running
docker rm $(DOCKER_NAME)
rm_serveri:
rm_dockeri:
docker stop $(DOCKER_NAME) || echo not running
docker rm $(DOCKER_NAME) || echo go on ...
docker image rm $(IMAGE_NAME)
docker image rm $(DOCKER_NAME)
B =/bin/bash
it:
docker exec -it $(D) $(DOCKER_NAME) $(B)
its:
docker exec -it $(D) $(DOCKER_NAME) /bin/bash
t:
docker exec -it $(D) $(DOCKER_NAME) /usr/bin/tail -n 100 -f /home/apache/error-ps.log
......
......@@ -2,20 +2,19 @@
FROM ubuntu:18.04 AS fdi
LABEL fdi 1.6
# 0.2-4 M. Huang <mhuang@nao.cas.cn>
# 1- M. Huang <mhuang@nao.cas.cn>
# 0.1 yuxin<syx1026@qq.com>
#ARG DEBIAN_FRONTEND=noninteractive
#ENV TZ=Etc/UTC
RUN apt-get update \
&& apt-get install -y apt-utils sudo nano net-tools\
&& apt-get install -y git python3-pip
&& apt-get install -y git python3-pip python3-venv \
&& rm -rf /var/lib/apt/lists/*
# rebuild mark
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}
......@@ -27,24 +26,30 @@ WORKDIR ${UHOME}
# config software
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)'
# set fdi's virtual env
ENV FDIVENV=${UHOME}/.venv
RUN python3 -m venv ${FDIVENV}
# effectively activate fdi virtual env for ${USR}
ENV PATH="${FDIVENV}/bin:$PATH"
# this also upgrades pip
RUN pip3 install pipenv
# convinience aliases
# convenience 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
do chown -R ${USR}:${USR} $i; echo $i; done
#&& chmod 755 ${UHOME} ${UHOME}/.local ${UHOME}/.local/bin ${UHOME}/.local/bin/*
#&& chmod 755 ${UHOME}/.cache ${UHOME}/.cache/pip
# If install fdi repo, instead of package
# make dir for fdi.
......@@ -63,7 +68,13 @@ 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 sudo make install EXT="[DEV,SERV]"
#ENV FDIVENV ${PKGS_DIR}/${PKG}/.venv
ENV PIPENV_VENV_IN_PROJECT 1
#RUN make install I='-e .' \
RUN python -m pip install -e .[DEV,SERV] \
&& python3 -c 'import sys;print(sys.path)' && pip list
# If installing fdi package
# no [DEV] needed
......@@ -85,6 +96,7 @@ RUN --mount=type=secret,id=envs sudo cp /run/secrets/envs . \
&& sudo chown ${USR} envs \
&& for i in `cat ./envs`; do export $i; done \
&& ./dockerfile_entrypoint.sh no-run # modify pnslocal.py
#RUN bash -c 'for i in `sed -e 's/=.*$//g' ./envs`; do echo $i=${!i}, PPP ${GITPULLCSC} P%%%; done'
WORKDIR ${PKGS_DIR}/${PKG}/
RUN make test \
......@@ -95,4 +107,5 @@ WORKDIR ${UHOME}
RUN pwd; /bin/ls -la; \
date > build
ENTRYPOINT ["/home/fdi/dockerfile_entrypoint.sh"]
\ No newline at end of file
ENTRYPOINT ["/home/fdi/dockerfile_entrypoint.sh"]
# syntax=docker/dockerfile:1.2
FROM mhastro/fdi:v1
FROM mhastro/fdi:v1.2
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
&& apt-get install -y curl apache2 libapache2-mod-wsgi-py3 \
&& rm -rf /var/lib/apt/lists/*
# rebuild mark
ARG re=rebuild
......@@ -20,7 +21,9 @@ 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"
# use fdi's virtual env path. this effectively activates fdi's virtuakenv
# ENV PATH="${FDIVENV}:${UHOME}/.local/bin:$PATH"
RUN echo ${PATH}
# setup config files
RUN cp /home/fdi/.config/pnslocal.py .config/pnslocal.py
......@@ -42,10 +45,6 @@ RUN mkdir -p ${PROJ_DIR}/data \
#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}/
......@@ -67,8 +66,9 @@ 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/
# config software
# 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 \
......@@ -79,7 +79,7 @@ RUN --mount=type=secret,id=envs sudo cp /run/secrets/envs . \
WORKDIR ${UHOME}
RUN /bin/ls -la; \
RUN /bin/ls -la; echo $PATH \
date > build
ENTRYPOINT ["/home/apache/httppool_server_entrypoint_2.sh"]
......
......@@ -54,7 +54,6 @@ 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
#service apache2 reload && echo apache2 reloaded;
echo running apachectl in CMD...>> ~/lastent ;
/usr/sbin/apache2ctl -DFOREGROUND 2>&1 >> ~/lastent
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