Syncing relative parent path. eg ../auth

I use TSOA to auto generate openapi specefications for my API endpoints.
I use a client gen to automatically generate axios client files for my React app.
How do i pass swagger.json from all my microservices into a container?
My current structure.

├── garden.yml
├── mongo.garden.yml
├── packages
│ ├── auth.backend
│ │ ├── dist
│ │ │ └── swagger.json
│ │ ├── Dockerfile
│ │ ├── garden.yml
│ ├── chat.backend
│ │ ├── dist
│ │ │ └── swagger.json
│ │ ├── Dockerfile
│ │ ├── garden.yml
│ ├── clientgen
│ │ ├── Dockerfile
│ │ └── garden.yml
│ └── webclient
│ ├── Dockerfile.dev
│ ├── garden.yml

I pretty much just want to copy /dist/swagger.json from all backend services, to a folder in clientgen. But still sync that in development.

I pretty much

Hi @Trixxi

The best option for this case is probably to let the other modules be build dependencies in the clientgen module and copy the swagger.json files in the container.

In the clientgenGarden config:

kind: Module
name: clientgen
build: 
  dependencies: ["auth.backend", "chat.backend"]
buildArgs:
  AUTH_IMAGE: ${modules.auth-backend.outputs.deployment-image-id} 
  CHAT_IMAGE: ${modules.chat-backend.outputs.deployment-image-id} 
# ...

And in the clientgen Dockerfile you can copy the swagger from the built auth and chat images:

ARG AUTH_IMAGE
ARG CHAT_IMAGE

FROM ${AUTH_IMAGE} as auth-image
FROM ${CHAT_IMAGE} as chat-image

# ...

COPY --from  auth-image /app/dist/swagger.json /app/auth-image
COPY --from  chat-image /app/dist/swagger.json /app/chat-image

# ...

You’ll find a similar pattern in this example project.

Another approach is to build the Swagger spec locally and hoist the Garden config for clientgen to the project root.

That is, you can rename it to something like clientgen.garden.yml and move it to the root, and update config like so:

kind: Module
name: clientgen
include: [clientgen/**/*, chat.backend/dist/swagger.json, auth.backend/dist/swagger.json]
dockerfile: clientgen/Dockerfile
# ...

But this assumes that you have the Swagger spec built and available locally.