Use a volume or copy my artefacts into docker image I want to dockerize my php application and deploy it in production. Here is my application structure :
api
|
+-- src
+-- config
+-- vendor
+-- tests
+-- public

I need to embed api/* in my container, and I'm confused about the best approach.
Here is mine :

A light multi-stage docker image (around 85 mb but can be more optimized)
FROM php:7.4-fpm-alpine AS base

WORKDIR /var/www/html
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN apk update &amp;&amp; \
  docker-php-ext-install mysqli tokenizer pdo_mysql &amp;&amp; \
  curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

FROM base AS dev

COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug-dev.ini
RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS &amp;&amp; \
  pecl install xdebug-2.9.1 &amp;&amp; \
  docker-php-ext-enable xdebug &amp;&amp; \
  touch /tmp/xdebug.log &amp;&amp; \
  chmod -R 666 /tmp/xdebug.log &amp;&amp; \
  apk del -f .phpize-deps


A mounted volume (docker-compose.yml)
api:
  volumes:
    - ./api:/var/www/html
  command: composer install &amp;&amp; php-fpm;



I saw a lot of docker images using COPY .. instruction in Dockerfile instead of volumes. I believe COPY is great to copy small config files (or a small build for compiled languages), but it's not optimized to keep the images small (basic rule with docker).
Am I missing something?
For example, is it bad practice to handle volumes from outside the dev environment ?
To copy into the image or to mount volumes--my advice:

if the files will change infrequently, then copy them into the image, with the understanding that if they need to be modified, you will need to rebuild the image.
if you need to frequently change the files, or store some kind of state about the files (and re-use them with future container instances of the image), then mount them as volumes.