How to configure different dockerfile for development and production

前端 未结 4 418
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 00:49

I use docker for development and in production for laravel project. I have slightly different dockerfile for development and production. For example I am mounting local director

4条回答
  •  佛祖请我去吃肉
    2021-01-30 01:29

    You can use build args directly without providing additional sh script. Might look a little messy, though. But it works.

    Dockerfile must be like this:

    FROM alpine
    ARG mode
    RUN if [ "x$mode" = "xdev" ] ; then echo "Development" ; else echo "Production" ; fi
    

    And commands to check are:

    docker build -t app --build-arg mode=dev .
    docker build -t app --build-arg mode=prod .
    

提交回复
热议问题