{"id":611,"date":"2019-08-21T08:20:23","date_gmt":"2019-08-21T16:20:23","guid":{"rendered":"https:\/\/andrewwippler.com\/?p=611"},"modified":"2019-08-21T08:20:23","modified_gmt":"2019-08-21T16:20:23","slug":"use-the-same-dockerfile-please","status":"publish","type":"post","link":"https:\/\/andrewwippler.com\/2019\/08\/21\/use-the-same-dockerfile-please\/","title":{"rendered":"Use the same Dockerfile – please"},"content":{"rendered":"\n

As Containers have progressed, Docker has stood out as the defacto standard. As many of the laggards are coming up to speed, Dockerfiles can be seen in many open source repositories. With the addition to that, I have seen a few repos with a Dockerfile-prod<\/code>, Dockerfile-dev<\/code>, Dockerfile-test<\/code>, etc.

Additionally, you find an IF clause in the CMD<\/code> statement such as:<\/p>\n\n\n\n

CMD if [ \"$REACT_NODE_ENV\" = \"development\" ]; \\\n  then yarn dev;  \\\n  else yarn build && yarn start --only=production; \\\n  fi<\/code><\/pre>\n\n\n\n

To those repositories, I have one daunting question:<\/p>\n\n\n\n

WHY?<\/h2>\n\n\n\n

Container start commands can be overwritten at run time. Here is how to do it:<\/p>\n\n\n\n

# Dockerfile\nFROM alpine:3.6\n\nCMD echo \"production start command\"<\/code><\/pre>\n\n\n\n
# docker-compose.yml\nversion: '3'\nservices:\n  dev-server:\n    build: .\n    command: echo 'development start command'<\/code><\/pre>\n\n\n\n
# kubernetes-deployment.yml\napiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: cool-app\n  namespace: cool-app-testing\n  labels:\n    app: cool-app\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: cool-app\n  template:\n    metadata:\n      labels:\n        app: cool-app\n    spec:\n      containers:\n      - name: cool-app\n        image: alpine:3.6\n        command:\n        - echo\n        - 'testing start command'<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

As Containers have progressed, Docker has stood out as the defacto standard. As many of the laggards are coming up to speed, Dockerfiles can be seen in many open source repositories. With the addition to that, I have seen a few repos with a Dockerfile-prod, Dockerfile-dev, Dockerfile-test, etc. Additionally, you find an IF clause in […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[6,11],"tags":[75,83],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/611"}],"collection":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/comments?post=611"}],"version-history":[{"count":2,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/611\/revisions"}],"predecessor-version":[{"id":614,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/611\/revisions\/614"}],"wp:attachment":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/media?parent=611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/categories?post=611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/tags?post=611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}