Last active
September 15, 2021 11:11
-
-
Save kougazhang/6a62116d79b279e1f6f679dbb3a574cf to your computer and use it in GitHub Desktop.
分阶段打包 #Dockfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.6 as builder | |
RUN mkdir -p /home/filex | |
RUN mkdir -p /disk/ssd1 | |
WORKDIR /home/filex | |
ARG project | |
COPY ./filex/$project . | |
FROM builder as job | |
# 注意,如果 stage 中想要使用 ARG 需要重新在此重新定义 | |
# refer: An ARG instruction goes out of scope at the end of the build stage where it was defined. | |
# To use an arg in multiple stages, each stage must include the ARG instruction. | |
# https://stackoverflow.com/questions/53681522/share-variable-in-multi-stage-dockerfile-arg-before-from-not-substituted | |
CMD ["sh", "-c", "./share/job"] | |
FROM builder as rawlog | |
CMD ["sh", "-c", "./share/rawlog"] | |
FROM builder as upload | |
CMD ["sh", "-c", "./share/upload"] | |
# build image command | |
# --build-arg project=$(job), pass variable $(job) to dockerfile ARG project | |
# --target upload, assign stage upload | |
# docker build --build-arg project=$(job) --target upload -t filex-upload . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment