Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added debug dockerfiles that support opening a terminal and Enabled LTO for rust Projects #143

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ docker-build:
$(MAKE) -C sources $(MAKECMDGOALS)
$(MAKE) -C reactions $(MAKECMDGOALS)

docker-build-debug:
$(MAKE) -C control-planes $(MAKECMDGOALS)
$(MAKE) -C query-container $(MAKECMDGOALS)
$(MAKE) -C sources $(MAKECMDGOALS)
$(MAKE) -C reactions $(MAKECMDGOALS)

kind-load:
$(MAKE) -C control-planes $(MAKECMDGOALS)
$(MAKE) -C query-container $(MAKECMDGOALS)
Expand Down
4 changes: 4 additions & 0 deletions control-planes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ docker-build:
$(MAKE) -C mgmt_api $(MAKECMDGOALS)
$(MAKE) -C kubernetes_provider $(MAKECMDGOALS)

docker-build-debug:
$(MAKE) -C mgmt_api $(MAKECMDGOALS)
$(MAKE) -C kubernetes_provider $(MAKECMDGOALS)

kind-load:
$(MAKE) -C mgmt_api $(MAKECMDGOALS)
$(MAKE) -C kubernetes_provider $(MAKECMDGOALS)
Expand Down
33 changes: 33 additions & 0 deletions control-planes/kubernetes_provider/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM rust@sha256:8fae3b1a63a4dcfb6cf277a49fb5967ccbf479b9e9cee4588a077a9cb216e6d4 as builder
# rust:1.81-bullseye
RUN apt-get update && apt-get install -y protobuf-compiler cmake libc6-dev libssl-dev libclang-dev

WORKDIR /usr/src
COPY ./resource_provider_api ./resource_provider_api
RUN cargo new kubernetes_provider
WORKDIR /usr/src/kubernetes_provider
COPY ./kubernetes_provider/Cargo.toml .
RUN cargo fetch

COPY ./kubernetes_provider .
RUN cargo install --force --path .

FROM ubuntu:22.04
RUN apt-get update && apt-get install -y openssl curl libssl3 && rm -rf /var/lib/apt/lists/*
# gcr.io/distroless/cc-debian11
COPY --from=builder /usr/local/cargo/bin/kubernetes_provider /usr/local/bin/kubernetes_provider
CMD ["kubernetes_provider"]
4 changes: 4 additions & 0 deletions control-planes/kubernetes_provider/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ default: docker-build
docker-build:
docker buildx build .. -f ./Dockerfile -t $(IMAGE_PREFIX)/kubernetes-provider:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

docker-build-debug:
docker buildx build .. -f ./Dockerfile.debug -t $(IMAGE_PREFIX)/kubernetes-provider:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)


kind-load:
kind load docker-image $(IMAGE_PREFIX)/kubernetes-provider:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)

Expand Down
34 changes: 34 additions & 0 deletions control-planes/mgmt_api/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2024 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM rust@sha256:8fae3b1a63a4dcfb6cf277a49fb5967ccbf479b9e9cee4588a077a9cb216e6d4 as builder
# rust:1.81-bullseye
RUN apt-get update && apt-get install -y protobuf-compiler cmake libc6-dev libssl-dev libclang-dev

WORKDIR /usr/src
COPY ./infrastructure ./infrastructure
WORKDIR /usr/src/control-planes
COPY ./control-planes/resource_provider_api ./resource_provider_api
RUN cargo new mgmt_api
WORKDIR /usr/src/control-planes/mgmt_api
COPY ./control-planes/mgmt_api/Cargo.toml .
RUN cargo fetch
COPY ./control-planes/mgmt_api .
RUN cargo install --force --path .

FROM ubuntu:20.04
RUN apt-get update && apt-get install -y openssl curl libssl1.1 && rm -rf /var/lib/apt/lists/*
# gcr.io/distroless/cc-debian11
COPY --from=builder /usr/local/cargo/bin/mgmt_api /usr/local/bin/mgmt_api
CMD ["mgmt_api"]
3 changes: 3 additions & 0 deletions control-planes/mgmt_api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ default: docker-build
docker-build:
docker buildx build ../../ -f ./Dockerfile -t $(IMAGE_PREFIX)/api:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

docker-build-debug:
docker buildx build ../../ -f ./Dockerfile.debug -t $(IMAGE_PREFIX)/api:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

kind-load:
kind load docker-image $(IMAGE_PREFIX)/api:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ If you wish to override the default (latest) image tag, you can use the `DOCKER_
make docker-build DOCKER_TAG_VERSION="v1"
```

If you wish to build images that support opening a terminal, you can use the `docker-build-debug` target to build the images.
```sh
make docker-build-debug
```

If you are using Kind in your development workflow, you can load the built images to your kind cluster using the `kind-load` target:

```sh
Expand Down
5 changes: 5 additions & 0 deletions query-container/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ docker-build:
$(MAKE) -C query-host $(MAKECMDGOALS)
$(MAKE) -C view-svc $(MAKECMDGOALS)

docker-build-debug:
$(MAKE) -C publish-api $(MAKECMDGOALS)
$(MAKE) -C query-host $(MAKECMDGOALS)
$(MAKE) -C view-svc $(MAKECMDGOALS)

kind-load:
$(MAKE) -C publish-api $(MAKECMDGOALS)
$(MAKE) -C query-host $(MAKECMDGOALS)
Expand Down
29 changes: 29 additions & 0 deletions query-container/publish-api/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM rust@sha256:fd45a543ed41160eae2ce9e749e5b3c972625b0778104e8962e9bfb113535301 as builder
# rust:1.74
RUN apt-get update && apt-get install -y protobuf-compiler libcurl4 && apt-get clean

WORKDIR /usr/src
COPY . .
WORKDIR /usr/src
RUN cargo install --force --path .

FROM ubuntu:22.04
RUN apt-get update && apt-get install -y openssl curl libssl3 && rm -rf /var/lib/apt/lists/*
# gcr.io/distroless/cc
ENV RUST_BACKTRACE=1
COPY --from=builder /usr/local/cargo/bin/publish-api /usr/local/bin/publish-api
CMD ["publish-api"]
3 changes: 3 additions & 0 deletions query-container/publish-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ default: docker-build
docker-build:
docker buildx build . -t $(IMAGE_PREFIX)/query-container-publish-api:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

docker-build-debug:
docker buildx build . -f Dockerfile.debug -t $(IMAGE_PREFIX)/query-container-publish-api:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

kind-load:
kind load docker-image $(IMAGE_PREFIX)/query-container-publish-api:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)

Expand Down
29 changes: 29 additions & 0 deletions query-container/query-host/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM rust@sha256:8fae3b1a63a4dcfb6cf277a49fb5967ccbf479b9e9cee4588a077a9cb216e6d4 as builder
# rust:1.81-bullseye
RUN apt-get update && apt-get install -y protobuf-compiler cmake libc6-dev libssl-dev libclang-dev

WORKDIR /usr/src
COPY . .
WORKDIR /usr/src
RUN cargo install --path .

FROM ubuntu:20.04
RUN apt-get update && apt-get install -y openssl curl libssl1.1 && rm -rf /var/lib/apt/lists/*
# gcr.io/distroless/cc-debian11
ENV RUST_BACKTRACE=1
COPY --from=builder /usr/local/cargo/bin/query-host /usr/local/bin/query-host
CMD ["query-host"]
3 changes: 3 additions & 0 deletions query-container/query-host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ default: docker-build
docker-build:
docker buildx build . -t $(IMAGE_PREFIX)/query-container-query-host:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

docker-build-debug:
docker buildx build . -f Dockerfile.debug -t $(IMAGE_PREFIX)/query-container-query-host:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

kind-load:
kind load docker-image $(IMAGE_PREFIX)/query-container-query-host:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)

Expand Down
29 changes: 29 additions & 0 deletions query-container/view-svc/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM rust@sha256:8fae3b1a63a4dcfb6cf277a49fb5967ccbf479b9e9cee4588a077a9cb216e6d4 as builder
# rust:1.81-bullseye
RUN apt-get update && apt-get install -y protobuf-compiler cmake libc6-dev libssl-dev libclang-dev

WORKDIR /usr/src
COPY . .
WORKDIR /usr/src
RUN cargo install --force --path .

FROM ubuntu:22.04
RUN apt-get update && apt-get install -y openssl curl libssl3 && rm -rf /var/lib/apt/lists/*
# gcr.io/distroless/cc
ENV RUST_BACKTRACE=1
COPY --from=builder /usr/local/cargo/bin/view-svc /usr/local/bin/view-svc
CMD ["view-svc"]
3 changes: 3 additions & 0 deletions query-container/view-svc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ default: docker-build
docker-build:
docker buildx build . -t $(IMAGE_PREFIX)/query-container-view-svc:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

docker-build-debug:
docker buildx build . -f Dockerfile.debug -t $(IMAGE_PREFIX)/query-container-view-svc:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

kind-load:
kind load docker-image $(IMAGE_PREFIX)/query-container-view-svc:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)

Expand Down
11 changes: 11 additions & 0 deletions reactions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ docker-build:
$(MAKE) -C platform/result-reaction $(MAKECMDGOALS)
$(MAKE) -C power-platform/dataverse/dataverse-reaction $(MAKECMDGOALS)

docker-build-debug:
$(MAKE) -C platform/debug-reaction $(MAKECMDGOALS)
$(MAKE) -C signalr/signalr-reaction $(MAKECMDGOALS)
$(MAKE) -C azure/eventgrid-reaction $(MAKECMDGOALS)
$(MAKE) -C azure/storagequeue-reaction $(MAKECMDGOALS)
$(MAKE) -C sql/storedproc-reaction $(MAKECMDGOALS)
$(MAKE) -C gremlin/gremlin-reaction $(MAKECMDGOALS)
$(MAKE) -C debezium/debezium-reaction $(MAKECMDGOALS)
$(MAKE) -C platform/result-reaction $(MAKECMDGOALS)
$(MAKE) -C power-platform/dataverse/dataverse-reaction $(MAKECMDGOALS)

kind-load:
$(MAKE) -C platform/debug-reaction $(MAKECMDGOALS)
$(MAKE) -C signalr/signalr-reaction $(MAKECMDGOALS)
Expand Down
4 changes: 2 additions & 2 deletions reactions/azure/eventgrid-reaction/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY . .
RUN dotnet restore
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS final
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS final
WORKDIR /app
COPY --from=build /app/build .
ENTRYPOINT ["/app/eventgrid-reaction"]
ENTRYPOINT ["/app/eventgrid-reaction"]
27 changes: 27 additions & 0 deletions reactions/azure/eventgrid-reaction/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-cbl-mariner2.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build

FROM --platform=$TARGETPLATFORM ubuntu:22.04 AS debug
RUN apt-get update && apt-get install -y bash curl dotnet-runtime-8.0 aspnetcore-runtime-8.0 && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/build .
ENTRYPOINT ["/app/eventgrid-reaction"]
3 changes: 3 additions & 0 deletions reactions/azure/eventgrid-reaction/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ default: docker-build
docker-build:
docker buildx build . -t $(IMAGE_PREFIX)/reaction-eventgrid:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

docker-build-debug:
docker buildx build . -f Dockerfile.debug -t $(IMAGE_PREFIX)/reaction-eventgrid:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

kind-load:
kind load docker-image $(IMAGE_PREFIX)/reaction-eventgrid:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)

Expand Down
4 changes: 2 additions & 2 deletions reactions/azure/storagequeue-reaction/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY . .
RUN dotnet restore
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS final
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS final
WORKDIR /app
COPY --from=build /app/build .
ENTRYPOINT ["/app/storagequeue-reaction"]
ENTRYPOINT ["/app/storagequeue-reaction"]
26 changes: 26 additions & 0 deletions reactions/azure/storagequeue-reaction/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2024 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-cbl-mariner2.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build

FROM --platform=$TARGETPLATFORM ubuntu:22.04 AS debug
RUN apt-get update && apt-get install -y bash curl dotnet-runtime-8.0 aspnetcore-runtime-8.0 && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/build .
ENTRYPOINT ["/app/storagequeue-reaction"]
3 changes: 3 additions & 0 deletions reactions/azure/storagequeue-reaction/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ default: docker-build
docker-build:
docker buildx build . -t $(IMAGE_PREFIX)/reaction-storage-queue:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

docker-build-debug:
docker buildx build . -f Dockerfile.debug -t $(IMAGE_PREFIX)/reaction-storage-queue:$(DOCKER_TAG_VERSION) $(DOCKERX_OPTS)

kind-load:
kind load docker-image $(IMAGE_PREFIX)/reaction-storage-queue:$(DOCKER_TAG_VERSION) --name $(CLUSTER_NAME)

Expand Down
2 changes: 1 addition & 1 deletion reactions/debezium/debezium-reaction/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY . .
RUN dotnet restore
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS final
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS final
WORKDIR /app
COPY --from=build /app/build .
ENTRYPOINT ["/app/debezium-reaction"]
Loading
Loading