Coder Social home page Coder Social logo

Comments (5)

zephinzer avatar zephinzer commented on May 14, 2024

Could you elaborate on a flow you’d use from the CLI with GoDev?

from godev.

DanielHabenicht avatar DanielHabenicht commented on May 14, 2024

Something like this: https://github.com/lukehoban/webapp-go/tree/debugging

In short: Having the ability to start docker-compose run debug and the hook up VSCode Remote Debugging. It would be nice to set some commands and flags to debug, but this is handled in #17.

from godev.

zephinzer avatar zephinzer commented on May 14, 2024

@DanielHabenicht interesting, this will be useful- I’m relatively new to Go so let me play around with it for awhile first to get a hang of how to use it before I work on this!

from godev.

DanielHabenicht avatar DanielHabenicht commented on May 14, 2024

Me too. :)
I couldn't get it to work with the example repo, but have previously debugged successfully in your containers.
If I find out how I got it working in your go-container I will post an update.

from godev.

rodrigo-garcia-edo avatar rodrigo-garcia-edo commented on May 14, 2024

You can debug with delve with a docker/ docker-compose setup like this
I am still figuring out how to fix the breakpoint detection in the IDE (there is something related with file paths that makes debug listen but do not detect path mappings).. but shouldn't be far from this.

FROM golang:1.12-alpine AS build-env

WORKDIR /ms-skeleton-go

COPY . .

RUN apk add --no-cache git \
    # Compile Delve for debug
    && go get -u github.com/go-delve/delve/cmd/dlv \
    && CGO_ENABLE=0 go install -tags netgo -v -gcflags "all=-N -l" -ldflags "-X main.version=unknown -X 'main.build=$(date)'" ./...

FROM alpine:3.9

COPY --from=build-env /go/bin/cmd /service
COPY --from=build-env /go/bin/dlv /debugger

# Allow delve to run on Alpine based containers.
RUN apk add --no-cache libc6-compat

# application 8080, delve 40000
EXPOSE 8080 40000

# Service
#ENTRYPOINT ["/service"]

# Run delve
CMD ["/debugger", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/service"]

in docker-compose.yml

app:
    env_file:
      - .env
    build: .
    security_opt:
      - apparmor:unconfined # for delve debugger
    cap_add:
      - SYS_PTRACE  # needed to allow the containers to read /proc/$PID (delve debugger)
    mem_limit: 64m
    memswap_limit: 0
    mem_swappiness: 0
    depends_on:
      mariadb:
        condition: service_started
    restart: on-failure
    ports:
      - 8080:8080
      - 40000:40000

from godev.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.