D
Dokploy3mo ago
arobius

Deploying a monorepo with docker compose: Help understanding Dokploy build environment & process.

I'm trying to deploy a monorepo (using turbo repo): project/ ├── apps/ │ ├── api/ # NestJS backend application │ ├── admin/ # React admin interface │ └── web # nextjs application frontend │ ├── packages/ │ ├── interfaces/ # Shared interfaces and types │ └── database/ # Shared database configuration ├── .gitignore ├── package.json # Root package.json ├── pnpm-workspace.yaml # PNPM workspace configuration └── turbo.json # Turborepo configuration I can successfully build the entire monorepo locally, and using a GitLab CI pipeline without issues. However when I try to build the same repo with Dokploy i get various build errors. Some of the errors were because I have 3 different docker-compose files: - docker-compose.yaml: Base file that other files inherit from - docker-compose.override.yaml: override file thats used for development - docker-compose.prod.yaml: Intended to be used for production. Dokploys build process doesn't seem to be able to understand the relationship between the files since it gives errors saying 'image is not defined' for some of the containers (they are defined in the base file) so I had to create a 4th docker-compose specifically for it that defines everything. But the issues continue, especially around building the shared packages. For example when it's building the api it needs to build the database then the interfaces first. The database building succeeds but then the interface fails due to an error about not being able to find the 'database' package even though it was just built in the previous step. Refer to attached image I just generally want to better understand the Dokploy build environment and how it differs from locally building or building through a CI environment so I can understand the modifications I'd need to make in my Dockerfiles, package.json's or docker-compose.yaml.
No description
1 Reply
arobius
arobiusOP3mo ago
I resolved it by explicitly copy all the required files and packages for each stage. Below is part of my Dockerfile for one of the applications: Build stage for production FROM base AS builder Copy package files COPY package.json pnpm-lock.yaml ./ COPY apps/admin/package.json ./apps/admin/ COPY packages/interfaces/package.json ./packages/interfaces/ COPY packages/database/package.json ./packages/database/ Install dependencies RUN pnpm install Copy source files COPY . . Build the application RUN echo "[admin] Building database package..." && \ cd packages/database && \ pnpm install && \ pnpm build && \ cd ../.. && \ echo "Building interfaces package..." && \ cd packages/interfaces && \ pnpm install && \ pnpm build && \ cd ../.. && \ echo "Building admin..." && \ cd apps/admin && \ pnpm install && \ pnpm build

Did you find this page helpful?