[英]create a dockerfile to run python and groovy app
I am working on a project which is using both python and groovy to scrap data from websites and do some engineering on that data.我正在开发一个项目,该项目同时使用 python 和 groovy 从网站上抓取数据并对这些数据进行一些工程。
I want to create a dockerfile which should have a python(3.6.5) as base image and java8 and groovy should be installed on it to run my code.我想创建一个 dockerfile,它应该有一个 python(3.6.5) 作为基本映像,并且应该在其上安装 java8 和 groovy 来运行我的代码。
the dockerfile I have right now is working for all the python codes(image : FROM python:3.6.5) but failing for groovy script and I cant find a solution which I can use to install groovy in dockerfile.我现在拥有的 dockerfile 适用于所有 python 代码(图像:FROM python:3.6.5),但对于 groovy 脚本失败,我找不到可以用来在 dockerfile 中安装 groovy 的解决方案。
is there anyone who has a dockerfile solving this part problem ?有没有人有解决这部分问题的 dockerfile ?
FROM python:3.6.5 RUN sh -c "ls /usr/local/lib" RUN sh -c "cat /etc/*-release" # Contents of requirements.txt each on a separate line for incremental builds RUN pip install SQLAlchemy==1.2.7 RUN pip install pandas==0.23.0 RUN pip uninstall bson RUN pip install pymongo RUN pip install openpyxl==2.5.3 RUN pip install joblib RUN pip install impyla RUN sh -c "mkdir -p /src/dateng" ADD . /src/dateng RUN sh -c "ls /src/dateng" WORKDIR /src/dateng/ ENTRYPOINT ["python", "/src/dateng/_aws/trigger.py"]
You don't need to use sh -c command
, just RUN command
and we should not use a RUN instruction per command, intead we should group them in only one RUN
, because each RUN
is a separated layer in the docker image, thus increasing the final size of it.你不需要使用
sh -c command
,只需要RUN command
,我们不应该为每个命令使用 RUN 指令,intead 我们应该只将它们分组在一个RUN
,因为每个RUN
是 docker 镜像中的一个单独的层,从而增加它的最终大小。
Inspired in this Dockerfile I use for a Python demo:受此Dockerfile 的启发,我用于 Python 演示:
FROM python:3.6.5
ARG CONTAINER_USER="python"
ARG CONTAINER_UID="1000"
# Will not prompt for questions
ENV DEBIAN_FRONTEND=noninteractive \
CONTAINER_USER=python \
CONTAINER_UID=1000
RUN apt update && \
apt -y upgrade && \
apt -y install \
ca-certificates \
locales \
tzdata \
inotify-tools \
python3-pip \
groovy && \
locale-gen en_GB.UTF-8 && \
dpkg-reconfigure locales && \
#https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
printf "fs.inotify.max_user_watches=524288\n" >> /etc/sysctl.conf && \
useradd -m -u ${CONTAINER_UID} -s /bin/bash ${CONTAINER_USER}
ENV LANG=en_GB.UTF-8 \
LANGUAGE=en_GB:en \
LC_ALL=en_GB.UTF-8
USER ${CONTAINER_USER}
RUN pip3 install \
fSQLAlchemy==1.2.7 \
pandas==0.23.0 \
pymongo \
openpyxl==2.5.3 \
joblib \
impyla && \
pip3 uninstall bson
# pip install will put the executables under ~/.local/bin
ENV PATH=/home/"${CONTAINER_USER}"/.local/bin:$PATH
WORKDIR /home/${CONTAINER_USER}/workspace
ADD . /home/${CONTAINER_USER}/dataeng
EXPOSE 5000
ENTRYPOINT ["python", "/home/python/dateng/_aws/trigger.py"]
NOTE : I am behind a corporate firewall, therefore I cannot test building this image as it is now, because I would need to add stuff to it that you don't need.
注意:我在公司防火墙后面,因此我无法像现在一样测试构建此映像,因为我需要向其中添加您不需要的内容。 Let me know if something doesn't work for you and I will work it out from home.
如果有什么不适合你,请告诉我,我会在家解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.