Use additional_contexts to copy platform server package into the Docker build context. Rewrites the file: dependency path and removes the lockfile so npm install can resolve the local package correctly. Applied to both production and dev Dockerfiles.
31 lines
718 B
Docker
31 lines
718 B
Docker
# Development Dockerfile with hot reload
|
|
FROM node:18-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy platform server package from additional build context
|
|
COPY --from=platform-server . /app/platform-server/
|
|
RUN rm -rf /app/platform-server/node_modules
|
|
|
|
# Install nodemon for hot reload
|
|
RUN npm install -g nodemon
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Rewrite file: dependency to use the local copy inside the container
|
|
RUN sed -i 's|file:../../cc-platform-core/server|file:./platform-server|' package.json \
|
|
&& rm -f package-lock.json
|
|
|
|
# Install all dependencies (including dev)
|
|
RUN npm install
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Expose ports
|
|
EXPOSE 3001 3002
|
|
|
|
# Start with nodemon for hot reload
|
|
CMD ["nodemon", "server.js"]
|