Dockerfile sed命令记录
FROM 172.16.1.60:5000/airflow-centos7-python3.6-base:latestENV AIRFLOW_HOME /opt/app/airflow-agentENV SLUGIFY_USES_TEXT_UNIDECODE yesENV GIT_DAGS git@gitlab.youxin.com:devops/airflow-dags.gitENV...
·
FROM 172.16.1.60:5000/airflow-centos7-python3.6-base:latest
ENV AIRFLOW_HOME /opt/app/airflow-agent
ENV SLUGIFY_USES_TEXT_UNIDECODE yes
ENV GIT_DAGS git@gitlab.youxin.com:devops/airflow-dags.git
ENV MQ_QUEUE test-exchange-docker
#add airflow配置文件
ADD /conf/ /opt/app/airflow-agent
#添加git仓库key
ADD /ssh/ /root/.ssh
RUN pip3 install -r /opt/app/airflow-agent/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple\
&& sed -i -e '35s/ask/no/' -e '35s/#//' /etc/ssh/ssh_config \
&& chmod +x /opt/app/airflow-agent/run.sh \
&& chmod +x /opt/app/airflow-agent/run-worker.sh \
&& chmod 400 /root/.ssh/id_rsa \
&& sed -i -e '27afrom airflow import configuration as conf' -e '27atry:' -e '27a\ \ \ \ tz = conf.get("core", "default_timezone")' -e '27a\ \ \ \ if tz == "system":' -e '27a\ \ \ \ \ \ \ \ utc = pendulum.local_timezone()' -e '27a\ \ \ \ else:' -e '27a\ \ \ \ \ \ \ \ utc = pendulum.timezone(tz)' -e '27aexcept Exception:' -e '27a\ \ \ \ pass' -e '61c\ \ \ \ d = dt.datetime.now()' /usr/local/lib/python3.6/site-packages/airflow/utils/timezone.py \
&& sed -i -e '37afrom airflow import configuration as conf' -e '37atry:' -e '37a\ \ \ \ tz = conf.get("core", "default_timezone")' -e '37a\ \ \ \ if tz == "system":' -e '37a\ \ \ \ \ \ \ \ utc = pendulum.local_timezone()' -e '37a\ \ \ \ else:' -e '37a\ \ \ \ \ \ \ \ utc = pendulum.timezone(tz)' -e '37aexcept Exception:' -e '37a\ \ \ \ pass' /usr/local/lib/python3.6/site-packages/airflow/utils/sqlalchemy.py \
&& sed -i -e '31c\ \ \ \ var UTCseconds = x.getTime();' -e '34c\ \ \ \ \ \ \ \ "timeFormat":"H:i:s", ' /usr/local/lib/python3.6/site-packages/airflow/www/templates/admin/master.html
EXPOSE 8080
EXPOSE 8793
CMD ["/opt/app/airflow-agent/run.sh"]
在制作airflow docker镜像时,需要修改airflow源码,使其显示时间为本地时间,通过 sed命令可实现对镜像中文件的修改。
通过指定行号修改:
在指定行号后增加内容:sed -i -e ‘行号a内容’ 文件路径
替换指定行号的内容:sed -i -e ‘行号c内容’ 文件路径
在指定行号前增加内容:sed -i -e ‘行号i内容’ 文件路径
也可以通过匹配内容进行修改:
匹配行前修改:sed -i '/要匹配的内容/a修改后的内容' 文件路径
匹配行后修改:sed -i '/要匹配的内容/i修改后的内容' 文件路径
替换匹配行:sed -i '/要匹配的内容/c替换后的内容' 文件路径
更多推荐
已为社区贡献2条内容
所有评论(0)