title: How to create a common base docker image for flask and celery applications
body: <p>My project using flask and celery libraries. I have deployed my application in AWS ECS Fargate.  Here are the two docker files for flask and celery.</p>
  
  <pre><code># Flask Docker File
  FROM python:3.6
  
  RUN apt-get update -y
  
  RUN pip3 install pipenv
  
  ENV USER dockeruser
  RUN useradd -ms /bin/bash $USER
  
  ENV APP_PATH /home/$USER/my_project
  RUN mkdir -p $APP_PATH
  COPY . $APP_PATH
  WORKDIR $APP_PATH
  
  RUN chown -R $USER:$USER $APP_PATH
  
  RUN pipenv install --system --deploy
  
  USER $USER
  
  EXPOSE 5000
  
  CMD gunicorn run:my_app -b 0.0.0.0:5000 -w 4
  </code></pre>
  
  <pre><code># Celery Docker File
  FROM python:3.6
  
  RUN apt-get update -y
  
  RUN pip3 install pipenv
  
  ENV USER dockeruser
  RUN useradd -ms /bin/bash $USER
  
  ENV APP_PATH /home/$USER/my_project
  RUN mkdir -p $APP_PATH
  COPY . $APP_PATH
  WORKDIR $APP_PATH
  
  RUN chown -R $USER:$USER $APP_PATH
  
  RUN pipenv install --system --deploy
  
  USER $USER
  
  CMD celery -A celery_tasks.celery worker -l INFO -E --autoscale=2,1 -Q apple,ball,cat
  </code></pre>
  
  <p>Both docker files are the same for celery and flask application. Is there is a way to create a common base image file both docker files? I am using AWS ECR to store docker images.</p>