fix(docker): clone platform from git instead of additional_contexts
The additional_contexts approach required cc-platform-core to exist on the Docker host at a relative path. This fails on servers where the repo layout differs. Instead, use a multi-stage build: stage 1 clones cc-platform-core from Gitea (depth 1), stage 2 copies server/ into the app and rewrites the file: path. Fully self-contained — no host deps. Applied to both production and dev Dockerfiles.
This commit is contained in:
@@ -6,8 +6,6 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./server
|
context: ./server
|
||||||
dockerfile: Dockerfile.dev
|
dockerfile: Dockerfile.dev
|
||||||
additional_contexts:
|
|
||||||
platform-server: ../cc-platform-core/server
|
|
||||||
container_name: turtle-server-dev
|
container_name: turtle-server-dev
|
||||||
ports:
|
ports:
|
||||||
- "3001:3001"
|
- "3001:3001"
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./server
|
context: ./server
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
additional_contexts:
|
|
||||||
platform-server: ../cc-platform-core/server
|
|
||||||
container_name: turtle-server
|
container_name: turtle-server
|
||||||
ports:
|
ports:
|
||||||
- "4200:3001" # HTTP API + WebSocket (unified)
|
- "4200:3001" # HTTP API + WebSocket (unified)
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
# Node.js backend
|
# Stage 1: Fetch platform server package from git
|
||||||
|
FROM alpine:3.20 AS platform
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
ARG PLATFORM_REPO=https://git.spatulaa.com/MayaTheShy/cc-platform-core.git
|
||||||
|
ARG PLATFORM_BRANCH=master
|
||||||
|
RUN git clone --depth 1 --branch "$PLATFORM_BRANCH" "$PLATFORM_REPO" /src \
|
||||||
|
&& rm -rf /src/server/node_modules /src/.git
|
||||||
|
|
||||||
|
# Stage 2: Node.js backend
|
||||||
FROM node:18-alpine
|
FROM node:18-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy platform server package from additional build context
|
# Copy platform server package from the git-clone stage
|
||||||
COPY --from=platform-server . /app/platform-server/
|
COPY --from=platform /src/server /app/platform-server/
|
||||||
RUN rm -rf /app/platform-server/node_modules
|
|
||||||
|
|
||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
# Development Dockerfile with hot reload
|
# Stage 1: Fetch platform server package from git
|
||||||
|
FROM alpine:3.20 AS platform
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
ARG PLATFORM_REPO=https://git.spatulaa.com/MayaTheShy/cc-platform-core.git
|
||||||
|
ARG PLATFORM_BRANCH=master
|
||||||
|
RUN git clone --depth 1 --branch "$PLATFORM_BRANCH" "$PLATFORM_REPO" /src \
|
||||||
|
&& rm -rf /src/server/node_modules /src/.git
|
||||||
|
|
||||||
|
# Stage 2: Development with hot reload
|
||||||
FROM node:18-alpine
|
FROM node:18-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy platform server package from additional build context
|
# Copy platform server package from the git-clone stage
|
||||||
COPY --from=platform-server . /app/platform-server/
|
COPY --from=platform /src/server /app/platform-server/
|
||||||
RUN rm -rf /app/platform-server/node_modules
|
|
||||||
|
|
||||||
# Install nodemon for hot reload
|
# Install nodemon for hot reload
|
||||||
RUN npm install -g nodemon
|
RUN npm install -g nodemon
|
||||||
|
|||||||
Reference in New Issue
Block a user