'Docker | How to prevent having to rebuild image on code changes

I started using Docker for a personal project and realized that this increases my development time to an unnacceptable amount. I would rather spin up an LXC instance if I had to rebuild images for every code change.

I heard there was a way to mount this but wasn't sure exactly how one would go about it. I also have a docker compose yaml file but I think you mount a volume or something in the Dockerfile? The goal is to have code changes not need to rebuild a container image.

FROM ubuntu:18.04
EXPOSE 5000

# update apt
RUN apt-get update -y
RUN apt-get install -y --no-install-recommends build-essential gcc wget

# pip installs
FROM python:3.10

# TA-Lib
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
  tar -xvzf ta-lib-0.4.0-src.tar.gz && \
  cd ta-lib/ && \
  ./configure && \
  make && \
  make install

RUN rm -R ta-lib ta-lib-0.4.0-src.tar.gz

ADD app.py /
RUN pip install --upgrade pip setuptools
RUN pip install pymysql
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
RUN pip freeze >> /tmp/requirement.txt

COPY . /tmp
CMD ["python", "/tmp/app.py"]

RUN chmod +x ./tmp/start.sh
RUN ./tmp/start.sh
version: '3.8'
services: 
  db:
    image: mysql:8.0.28
    command: '--default-authentication-plugin=mysql_native_password'
    restart: always
    environment:
      - MYSQL_DATABASE=#########
      - MYSQL_ROOT_PASSWORD=####

  # client:
  #   build: client
  #   ports: [3000]
  #   restart: always

  server:
    build: server
    ports: [5000]
    restart: always


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source