mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-04 16:56:56 +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/
|
||||
ports:
|
||||
- 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
|
||||
image: aimvector/golang:1.0.0
|
||||
build:
|
||||
context: ./golang
|
||||
target: prod
|
||||
#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
|
||||
target: debug
|
||||
volumes:
|
||||
- ./golang/src/:/work
|
||||
- ./golang/src/:/go/src/work/
|
||||
ports:
|
||||
- 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
|
||||
container_name: nodejs
|
||||
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
|
||||
|
||||
# installing git
|
||||
RUN apk update && apk upgrade && \
|
||||
apk add --no-cache git
|
||||
|
||||
RUN go get github.com/sirupsen/logrus
|
||||
RUN go get github.com/buaazp/fasthttprouter
|
||||
RUN go get github.com/valyala/fasthttp
|
||||
|
||||
WORKDIR /work
|
||||
COPY ./src /work/
|
||||
RUN go build -o app
|
||||
###########START NEW IMAGE###################
|
||||
|
||||
FROM alpine:3.9 as prod
|
||||
COPY --from=dev /work/app /
|
||||
CMD ./app
|
||||
FROM golang:1.12.5-alpine3.9 as debug
|
||||
|
||||
# installing git
|
||||
RUN apk update && apk upgrade && \
|
||||
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/buaazp/fasthttprouter
|
||||
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/
|
||||
|
||||
RUN go build -o app
|
||||
### Run the Delve debugger ###
|
||||
COPY ./dlv.sh /
|
||||
RUN chmod +x /dlv.sh
|
||||
ENTRYPOINT [ "/dlv.sh"]
|
||||
|
||||
###########START NEW IMAGE###################
|
||||
|
||||
FROM alpine:3.9 as prod
|
||||
COPY --from=debug /go/src/work/app /
|
||||
CMD ./app
|
||||
|
@ -8,14 +8,12 @@ import (
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
var searchMock []byte
|
||||
|
||||
func Response(ctx *fasthttp.RequestCtx) {
|
||||
fmt.Fprintf(ctx, "Hello")
|
||||
}
|
||||
func main() {
|
||||
|
||||
fmt.Println("starting.")
|
||||
fmt.Println("starting...")
|
||||
|
||||
router := fasthttprouter.New()
|
||||
router.GET("/", Response)
|
||||
|
Loading…
x
Reference in New Issue
Block a user