fix(docker): resolve @cc-platform/server file: dep in container build
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.
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
services:
|
services:
|
||||||
server:
|
server:
|
||||||
build: ./server
|
build:
|
||||||
|
context: ./server
|
||||||
|
additional_contexts:
|
||||||
|
platform-server: ../../cc-platform-core/server
|
||||||
networks:
|
networks:
|
||||||
- inventory-network
|
- inventory-network
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -8,8 +8,16 @@ RUN apk add --no-cache python3 make g++ su-exec libstdc++
|
|||||||
|
|
||||||
WORKDIR /app
|
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
|
||||||
|
|
||||||
COPY package*.json ./
|
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
|
||||||
|
|
||||||
RUN npm install --omit=dev
|
RUN npm install --omit=dev
|
||||||
|
|
||||||
# Remove build tools after install to keep image small
|
# Remove build tools after install to keep image small
|
||||||
|
|||||||
Reference in New Issue
Block a user