From 5dfc15b14066a39e932eae512752ef057a3dfe84 Mon Sep 17 00:00:00 2001 From: Gustavo Massaneiro Date: Fri, 31 Dec 2021 15:37:32 -0300 Subject: [PATCH] update dockerfile for debug --- debug.Dockerfile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/debug.Dockerfile b/debug.Dockerfile index e063e887f..dd5c1c0dd 100644 --- a/debug.Dockerfile +++ b/debug.Dockerfile @@ -3,11 +3,12 @@ FROM node:14-slim AS site-build WORKDIR /app/ui-build -COPY ui . +COPY ui/package.json . +COPY ui/package-lock.json . RUN npm i +COPY ui . RUN npm run build - FROM golang:1.16-alpine AS builder # Set necessary environment variables needed for our image. ENV CGO_ENABLED=1 GOOS=linux GOARCH=amd64 @@ -34,6 +35,7 @@ ARG SEM_VER=0.0.0 COPY shared ../shared COPY tap ../tap COPY agent . +# Include gcflags for debugging RUN go build -gcflags="all=-N -l" -o mizuagent . # Download Basenine executable, verify the sha1sum and move it to a directory in $PATH @@ -45,10 +47,10 @@ RUN chmod +x ./basenine_linux_amd64 COPY devops/build_extensions_debug.sh .. RUN cd .. && /bin/bash build_extensions_debug.sh - FROM golang:1.16-alpine -RUN apk add bash libpcap-dev +# Set necessary environment variables needed for our image. +RUN apk add bash libpcap-dev gcc g++ WORKDIR /app @@ -57,9 +59,16 @@ COPY --from=builder ["/app/agent-build/mizuagent", "."] COPY --from=builder ["/app/agent-build/basenine_linux_amd64", "/usr/local/bin/basenine"] COPY --from=builder ["/app/agent/build/extensions", "extensions"] COPY --from=site-build ["/app/ui-build/build", "site"] +RUN mkdir /app/data/ -# install remote debugging tool +# install delve +ENV CGO_ENABLED=1 GOOS=linux GOARCH=amd64 RUN go get github.com/go-delve/delve/cmd/dlv -ENTRYPOINT "/app/mizuagent" -#CMD ["sh", "-c", "dlv --headless=true --listen=:2345 --log --api-version=2 --accept-multiclient exec ./mizuagent -- --api-server"] +ENV GIN_MODE=debug + +# delve ports +EXPOSE 2345 2346 + +# this script runs both apiserver and passivetapper and exits either if one of them exits, preventing a scenario where the container runs without one process +ENTRYPOINT "/app/mizuagent" \ No newline at end of file