How to reuse content-type files out of a docker container?

System Information
  • Strapi Version: 4.2.3
  • Operating System: docker
  • Database: postgresql
  • Node Version: 14.19.1
  • NPM Version: 6.14.16

Hi, I started a strapi project in a Dockerfile, but if I delete the docker container, the content-type files (inside /path-to/api folder) get deleted as well. Which is expected because they are generated within the docker container. I’ve extracted the files from the container and put them in the strapi’s main source folder. The database is the same as it’s been used by the container. When I try to start the project by the command “npm run build” and then “npm run develop” I get that


.

Question 1:
How to fix that error?

Question 2:
I’d like to use that custom docker container anyway as part of a docker-compose.yml script in a way that generated along with content-types files to be placed properly in the main source folder. I plan to do it by mounting the /path-to/api/src folder to /opt/app/src. Is it enought?

My current Dockerfile:

FROM node:14.19.1

ARG NODE_ENV=development
ARG API_PUBLIC_URL
ARG API_PUBLIC_ADMIN_URL

ENV NODE_ENV=${NODE_ENV}
ENV API_PUBLIC_URL=${API_PUBLIC_URL}
ENV API_PUBLIC_ADMIN_URL=${API_PUBLIC_ADMIN_URL}

WORKDIR /opt/
COPY ./package.json ./package-lock.json ./
ENV PATH /opt/node_modules/.bin:$PATH
RUN npm install
WORKDIR /opt/app

COPY ./ .

RUN npm run build

EXPOSE 1337
CMD ["npm", "run", "develop"]