56 lines
1.4 KiB
Plaintext
56 lines
1.4 KiB
Plaintext
# 配置参数(指定基础镜像版本)
|
|
ARG BASE_NAME=${BASE_NAME} \
|
|
BASE_TAG=${BASE_TAG}
|
|
|
|
# 基于基础镜像构建
|
|
FROM $BASE_NAME:$BASE_TAG
|
|
|
|
# 指定自定义标签
|
|
LABEL ${KEY1}=${VALUE1} ${KEY2}=${VALUE2} ${KEY3}=${VALUE3}
|
|
|
|
# 指定默认挂载的目录
|
|
VOLUME [${CONTAINER_DIR1},${CONTAINER_DIR2},${CONTAINER_DIR3}]
|
|
|
|
# 指定端口号
|
|
EXPOSE ${PORT1} ${PORT2} ${PORT3}
|
|
|
|
# 配置参数
|
|
ARG ${ARG1_NAME}=${ARG1_VALUE} \
|
|
${ARG2_NAME}=${ARG2_VALUE} \
|
|
${ARG3_NAME}=${ARG3_VALUE}
|
|
|
|
# 配置环境变量
|
|
ENV ${ENV1_NAME}=${ENV1_VALUE} \
|
|
${ENV2_NAME}=${ENV2_VALUE} \
|
|
${ENV3_NAME}=${ENV3_VALUE}
|
|
|
|
# 运行命令
|
|
RUN ${COMMAND1} && \
|
|
${COMMAND2} && \
|
|
${COMMAND3}
|
|
|
|
# 复制文件(仅复制)
|
|
COPY ${HOST_FILE1_NAME} ${CONTAINER_FILE1_PATH_AND_NAME}
|
|
COPY ${HOST_FILE2_NAME} ${CONTAINER_FILE2_PATH_AND_NAME}
|
|
COPY ${HOST_FILE3_NAME} ${CONTAINER_FILE3_PATH_AND_NAME}
|
|
|
|
# 复制文件(自动解压 tar、zip、xz 等压缩文件)
|
|
ADD ${HOST_FILE1_NAME} ${CONTAINER_FILE1_PATH_AND_NAME}
|
|
ADD ${HOST_FILE2_NAME} ${CONTAINER_FILE2_PATH_AND_NAME}
|
|
ADD ${HOST_FILE3_NAME} ${CONTAINER_FILE3_PATH_AND_NAME}
|
|
|
|
# 设置工作目录
|
|
WORKDIR ${CONTAINER_DIR}
|
|
|
|
# 设置启动用户
|
|
USER ${GROUP_NAME}:${USER_NAME}
|
|
|
|
# 设置监控检查
|
|
HEALTHCHECK ${HEALTHCHECK}
|
|
|
|
# 设置执行启动脚本( docker run 时不可覆盖)
|
|
ENTRYPOINT [${EXEC_FILE},${ARG1},${ARG2}]
|
|
|
|
# 设置执行启动脚本( docker run 时可以覆盖)
|
|
CMD [${EXEC_FILE},${ARG1},${ARG2}]
|