diff --git a/internal/adapter/templates/templates/components/service/Dockerfile.tmpl b/internal/adapter/templates/templates/components/service/Dockerfile.tmpl index 1653ac8..cb12421 100644 --- a/internal/adapter/templates/templates/components/service/Dockerfile.tmpl +++ b/internal/adapter/templates/templates/components/service/Dockerfile.tmpl @@ -14,6 +14,10 @@ WORKDIR /app COPY pkg/ ./pkg/ COPY services/{{COMPONENT_NAME}}/ ./services/{{COMPONENT_NAME}}/ +# Download dependencies (populates go.sum if empty) +RUN cd pkg && go mod download +RUN cd services/{{COMPONENT_NAME}} && go mod download + # Build from the service directory (uses replace directive for ../pkg) RUN cd services/{{COMPONENT_NAME}} && CGO_ENABLED=0 go build -o /{{COMPONENT_NAME}} ./cmd/server diff --git a/internal/adapter/templates/templates/components/worker/Dockerfile.tmpl b/internal/adapter/templates/templates/components/worker/Dockerfile.tmpl index b6094df..be5c530 100644 --- a/internal/adapter/templates/templates/components/worker/Dockerfile.tmpl +++ b/internal/adapter/templates/templates/components/worker/Dockerfile.tmpl @@ -14,6 +14,10 @@ WORKDIR /app COPY pkg/ ./pkg/ COPY workers/{{COMPONENT_NAME}}/ ./workers/{{COMPONENT_NAME}}/ +# Download dependencies (populates go.sum if empty) +RUN cd pkg && go mod download +RUN cd workers/{{COMPONENT_NAME}} && go mod download + # Build from the worker directory (uses replace directive for ../pkg) RUN cd workers/{{COMPONENT_NAME}} && CGO_ENABLED=0 go build -o /{{COMPONENT_NAME}} ./cmd/worker