mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-06 17:01:30 +00:00
debugging in go
This commit is contained in:
parent
914b6f4ab9
commit
cba88d61db
21
.vscode/launch.json
vendored
Normal file
21
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Remote Docker",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "remote",
|
||||||
|
"remotePath":"/go/src/work/",
|
||||||
|
"port": 2345,
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"program": "${workspaceFolder}/golang/src/",
|
||||||
|
"args": [],
|
||||||
|
"trace" : "verbose",
|
||||||
|
"env" : {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -14,20 +14,19 @@ services:
|
|||||||
- ./c#/src/:/work/
|
- ./c#/src/:/work/
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
golang: #docker run -it -v ${PWD}:/work -w /work -p 5001:5000 aimvector/golang:1.0.0 /bin/sh
|
golang: #docker run -it -v ${PWD}:/go/src/work -p 5001:5000 -p 2345:2345 --security-opt "seccomp:unconfined" aimvector/golang:1.0.0
|
||||||
container_name: golang
|
container_name: golang
|
||||||
image: aimvector/golang:1.0.0
|
image: aimvector/golang:1.0.0
|
||||||
build:
|
build:
|
||||||
context: ./golang
|
context: ./golang
|
||||||
target: prod
|
target: debug
|
||||||
#working_dir: /work #comment out for build.target:prod
|
|
||||||
#entrypoint: /bin/sh #comment out for build.target:prod
|
|
||||||
#stdin_open: true #comment out for build.target:prod
|
|
||||||
#tty: true #comment out for build.target:prod
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./golang/src/:/work
|
- ./golang/src/:/go/src/work/
|
||||||
ports:
|
ports:
|
||||||
- 5001:5000
|
- 5001:5000
|
||||||
|
- 2345:2345
|
||||||
|
security_opt:
|
||||||
|
- "seccomp:unconfined"
|
||||||
nodejs: #docker run -it -v ${PWD}:/work -w /work -p 5002:5000 aimvector/nodejs:1.0.0 /bin/sh
|
nodejs: #docker run -it -v ${PWD}:/work -w /work -p 5002:5000 aimvector/nodejs:1.0.0 /bin/sh
|
||||||
container_name: nodejs
|
container_name: nodejs
|
||||||
image: aimvector/nodejs:1.0.0
|
image: aimvector/nodejs:1.0.0
|
||||||
|
3
golang/dlv.sh
Normal file
3
golang/dlv.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd /go/src/work
|
||||||
|
dlv debug --headless --log -l 0.0.0.0:2345 --api-version=2
|
@ -1,18 +1,32 @@
|
|||||||
FROM golang:1.12.5-alpine3.9 as dev
|
FROM golang:1.12.5-alpine3.9 as debug
|
||||||
|
|
||||||
# installing git
|
# installing git
|
||||||
RUN apk update && apk upgrade && \
|
RUN apk update && apk upgrade && \
|
||||||
apk add --no-cache git
|
apk add --no-cache git \
|
||||||
|
dpkg \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
musl-dev
|
||||||
|
|
||||||
|
ENV GOPATH /go
|
||||||
|
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
|
||||||
|
|
||||||
RUN go get github.com/sirupsen/logrus
|
RUN go get github.com/sirupsen/logrus
|
||||||
RUN go get github.com/buaazp/fasthttprouter
|
RUN go get github.com/buaazp/fasthttprouter
|
||||||
RUN go get github.com/valyala/fasthttp
|
RUN go get github.com/valyala/fasthttp
|
||||||
|
RUN go get github.com/go-delve/delve/cmd/dlv
|
||||||
|
|
||||||
|
WORKDIR /go/src/work
|
||||||
|
COPY ./src /go/src/work/
|
||||||
|
|
||||||
WORKDIR /work
|
|
||||||
COPY ./src /work/
|
|
||||||
RUN go build -o app
|
RUN go build -o app
|
||||||
|
### Run the Delve debugger ###
|
||||||
|
COPY ./dlv.sh /
|
||||||
|
RUN chmod +x /dlv.sh
|
||||||
|
ENTRYPOINT [ "/dlv.sh"]
|
||||||
|
|
||||||
###########START NEW IMAGE###################
|
###########START NEW IMAGE###################
|
||||||
|
|
||||||
FROM alpine:3.9 as prod
|
FROM alpine:3.9 as prod
|
||||||
COPY --from=dev /work/app /
|
COPY --from=debug /go/src/work/app /
|
||||||
CMD ./app
|
CMD ./app
|
||||||
|
@ -8,14 +8,12 @@ import (
|
|||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var searchMock []byte
|
|
||||||
|
|
||||||
func Response(ctx *fasthttp.RequestCtx) {
|
func Response(ctx *fasthttp.RequestCtx) {
|
||||||
fmt.Fprintf(ctx, "Hello")
|
fmt.Fprintf(ctx, "Hello")
|
||||||
}
|
}
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
fmt.Println("starting.")
|
fmt.Println("starting...")
|
||||||
|
|
||||||
router := fasthttprouter.New()
|
router := fasthttprouter.New()
|
||||||
router.GET("/", Response)
|
router.GET("/", Response)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user