我有一个Dockerfile,我需要包含不同的行,这取决于我是在我的开发环境还是在树莓派上运行它。
我可以在唯一不同的行中添加某种依赖于体系结构的IF语句吗?
# ARM / Raspbian version. (shortened)
FROM node:10
COPY Gemfile* /usr/src/app/
WORKDIR /usr/src/app
RUN apt-get -y update
RUN apt-get -y install build-essential g++
RUN wget https://archive.raspbian.org/raspbian.public.key -O - | apt-key add -
RUN echo 'deb http://archive.raspbian.org/raspbian/ stretch main' > /etc/apt/sources.list
RUN apt-get -y update
RUN apt-get -y install ruby2.3 ruby2.3-dev
架构之间的适当来源各不相同。
#if targetEnvironment(simulator)
//simulator code
#else
#warning("Not compiling for simulator")
#endif
答案 0 :(得分:2)
在docker文件中,您可以使用FROM node:10
ARG platform=x64
为构建过程定义参数,如:
docker build --build-arg platform=arm
https://issuetracker.google.com/issues/79478779
您可以像这样调用它来更改默认值
RUN if [ "$platform" = "arm" ]; then ... else ... fi
并在您的docker文件中,它的行为与任何其他变量一样,因此您可以使用它:
extract_job = client.extract_table(
table_ref,
destination_uri,
# Location must match that of the source table.
location='US') # API request
extract_job.result()