Skip to content

Commit 18471b7

Browse files
committed
Merge branch 'master' into task-update-go
2 parents 3f8f8b4 + 0edc77e commit 18471b7

5 files changed

Lines changed: 125 additions & 47 deletions

File tree

Dockerfile

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1-
FROM golang:latest
1+
#
2+
# Compile step
3+
FROM golang:alpine AS build-env
4+
ENV GOPATH=/gopath
5+
ENV PATH=$GOPATH/bin:$PATH
6+
ADD . /gopath/src/github.com/dfeyer/flow-debugproxy
7+
RUN apk update && \
8+
apk upgrade && \
9+
apk add git
10+
RUN cd /gopath/src/github.com/dfeyer/flow-debugproxy \
11+
&& go get \
12+
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o flow-debugproxy
213

3-
WORKDIR /go/src/github.com/dfeyer/flow-debugproxy
4-
COPY . .
14+
#
15+
# Build step
16+
FROM alpine
17+
WORKDIR /app
518

6-
RUN go get -v
7-
RUN go install -v
19+
COPY --from=build-env /gopath/src/github.com/dfeyer/flow-debugproxy/flow-debugproxy /app/
820

9-
CMD ["flow-debugproxy"]
21+
ENV ADDITIONAL_ARGS ""
22+
23+
ENV XDEBUG_PORT 9010
24+
25+
ENV IDE_IP 127.0.0.1
26+
ENV IDE_PORT 9000
27+
28+
ENV FRAMEWORK "flow"
29+
30+
ENTRYPOINT ["sh", "-c", "./flow-debugproxy --xdebug 0.0.0.0:${XDEBUG_PORT} --framework ${FRAMEWORK} --ide ${IDE_IP}:${IDE_PORT} ${ADDITIONAL_ARGS}"]

README.md

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,40 +43,65 @@ Show help
4343
Use with Docker
4444
---------------
4545

46-
##### 1. Preparation:
47-
48-
You will need:
49-
1. Your (W)LAN IP address.
50-
2. Your docker-machine's IP address. CMD: `docker-machine ip default` (use 127.0.0.1 on linux)
51-
3. A compiled flow-debugproxy binary
52-
4. Access to the PHP container's php.ini
53-
5. xdebug must be working
54-
55-
##### 2. Installation & Debugging:
56-
57-
1. Copy the flow-debugproxy binary to your container or a mounted folder.
58-
2. Identify and set these environment variables or replace them in the upcoming commands:
59-
* `HOST_IP` (Primary (W)LAN address of your device)
60-
* `XDEBUG_PORT` (PhpStorm settings: Language & Framework -> PHP -> Debug: Xdebug: Debug Port)
61-
* `FLOW_DEBUG_BIN_PATH` (The path of the binary **inside** the container)
62-
3. Set following php.ini values in your php/web container: (xdebug will now try to (only) connect to the php container itself.)
46+
Use the [official docker image](https://hub.docker.com/r/dfeyer/flow-debugproxy/) and follow the instruction for the configuration.
47+
48+
##### PHP configuration
49+
6350
```
64-
xdebug.remote_host = 127.0.0.1
65-
xdebug.remote_port = 9002
51+
[Xdebug]
52+
zend_extension=/.../xdebug.so
53+
xdebug.remote_enable=1
54+
xdebug.idekey=PHPSTORM
55+
; The IP or name of the proxy container
56+
xdebug.remote_host=debugproxy
57+
; The proxy port (9010 by default, to not have issue is you use PHP FPM, already on port 9000)
58+
xdebug.remote_port=9010
59+
;xdebug.remote_log=/tmp/xdebug.log
6660
```
67-
4. Start the debug proxy (Replace `$(docker-compose ps -q app)` with your container if you don't use docker-compose)
61+
62+
You can use the `xdebug.remote_log` to debug the protocol between your container and the proxy, it's useful to catch network issues.
63+
64+
##### Docker Compose
65+
66+
This is an incomplete Docker Compose configuration:
67+
6868
```
69-
docker exec -e PHP_IDE_CONFIG='serverName=app' $(docker-compose ps -q app) ${FLOW_DEBUG_BIN_PATH} --xdebug 0.0.0.0:9002 --ide ${HOST_IP}:${XDEBUG_PORT} > /dev/null &
69+
services:
70+
debugproxy:
71+
image: dfeyer/flow-debugproxy:latest
72+
volumes:
73+
- .:/data
74+
environment:
75+
# This MUST be the IP address of the IDE (your computer)
76+
- "IDE_IP=192.168.1.130"
77+
# This is the default value, need to match the xdebug.remote_port on your php.ini
78+
- "XDEBUG_PORT=9010"
79+
# Use this to enable verbose debugging on the proxy
80+
# - "ADDITIONAL_ARGS=-vv --debug"
81+
networks:
82+
- backend
83+
84+
# This is your application containers, you need to link it to the proxy
85+
app:
86+
# The proxy need an access to the project files, to be able to do the path mapping
87+
volumes:
88+
- .:/data
89+
links:
90+
- debugproxy
7091
```
71-
5. Enable your IDE's xdebug listener, ensure xdebug is enabled (e.g. if you use bookm)
72-
6. Use `xdebug_break()` in your code to force your first break.
73-
7. The first time you have to configure your IDE with the popup that should open on the first `xdebug_break();` hit. (Or "Click to set up path mappings" in your debug console UI)
74-
If not, configure your PHP Server settings yourself.
7592

76-
Debugging the debugger:
93+
**Options summary:**
94+
* `IDE_IP` The primary local W-/LAN IP of your machine where your IDE runs on
95+
* `IDE_PORT` The Port your IDE is listening for incoming xdebug connections. (The port the debug proxy will try to connect to)
96+
* `XDEBUG_PORT` The port on which xdebug will try to establish a connection (to this container)
97+
* `FRAMEWORK` Currently supported values: `flow` and `dummy`
98+
* `ADDITIONAL_ARGS` For any additional argument like verbosity flags (`-vv`) or debug mode (`--debug`) (or both)
99+
100+
**Debugging the debugger**
77101

78102
Start the debug proxy with verbose flags if it does not connect to your IDE.
79-
The debug proxy does not quit after stopping the process that started it. You have to kill it in the container manually.
103+
The debug proxy does not quit after stopping the process that started it.
104+
You have to kill it in the container manually.
80105

81106
Hint:
82107

@@ -88,9 +113,11 @@ proxy classes.
88113
FLOW_PATH_TEMPORARY_BASE=/tmp/flow/Data/Temporary
89114
```
90115

91-
##### Using with --framework dummy
116+
Using with --framework dummy
117+
----------------------------
118+
119+
If your debugging target is the code generated by Flow's AOP Framework then you can start the debugging proxy with `--framework dummy`.
92120

93-
If your debugging target is the code generated by Flow's AOP Framework then you can start the debugging proxy with --framework dummy
94121
In that case it won't remap from the generated code to your source but "pass through" the debugger steps.
95122
To see what's going on you have to have the generated code in a folder visible to your IDE (in your project).
96123
You can either abstain from `FLOW_PATH_TEMPORARY_BASE` or set it to a path that is in your IDE's project.

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/dfeyer/flow-debugproxy
2+
3+
go 1.13
4+
5+
require (
6+
github.com/clbanning/mxj v1.8.4
7+
github.com/mattn/go-colorable v0.1.4 // indirect
8+
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
9+
github.com/urfave/cli v1.22.2
10+
)

go.sum

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
2+
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
3+
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
4+
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
5+
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
6+
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
7+
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
8+
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
9+
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
10+
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
11+
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
12+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
13+
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
14+
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
15+
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
16+
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
17+
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
18+
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
19+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
20+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
21+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
22+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

main.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
_ "github.com/dfeyer/flow-debugproxy/dummypathmapper"
1818
_ "github.com/dfeyer/flow-debugproxy/flowpathmapper"
1919

20-
"github.com/codegangsta/cli"
20+
"github.com/urfave/cli"
2121

2222
"net"
2323
"os"
@@ -28,51 +28,49 @@ func main() {
2828
app := cli.NewApp()
2929
app.Name = "flow-debugproxy"
3030
app.Usage = "Flow Framework xDebug proxy"
31-
app.Author = "Dominique Feyer"
32-
app.Email = "dominique@neos.io"
3331
app.Version = "1.0.1"
3432

3533
app.Flags = []cli.Flag{
36-
cli.StringFlag{
34+
&cli.StringFlag{
3735
Name: "xdebug, l",
3836
Value: "127.0.0.1:9000",
3937
Usage: "Listen address IP and port number",
4038
},
41-
cli.StringFlag{
39+
&cli.StringFlag{
4240
Name: "ide, I",
4341
Value: "127.0.0.1:9010",
4442
Usage: "Bind address IP and port number",
4543
},
46-
cli.StringFlag{
44+
&cli.StringFlag{
4745
Name: "context, c",
4846
Value: "Development",
4947
Usage: "The context to run as",
5048
},
51-
cli.StringFlag{
49+
&cli.StringFlag{
5250
Name: "localroot, r",
5351
Value: "",
5452
Usage: "Local project root for remote debugging",
5553
},
56-
cli.StringFlag{
54+
&cli.StringFlag{
5755
Name: "framework",
5856
Value: "flow",
5957
Usage: "Framework support, currently on Flow framework (flow) or Dummy (dummy) is supported",
6058
},
61-
cli.BoolFlag{
59+
&cli.BoolFlag{
6260
Name: "verbose",
6361
Usage: "Verbose",
6462
},
65-
cli.BoolFlag{
63+
&cli.BoolFlag{
6664
Name: "vv",
6765
Usage: "Very verbose",
6866
},
69-
cli.BoolFlag{
67+
&cli.BoolFlag{
7068
Name: "debug",
7169
Usage: "Show debug output",
7270
},
7371
}
7472

75-
app.Action = func(cli *cli.Context) {
73+
app.Action = func(cli *cli.Context) error {
7674
c := &config.Config{
7775
Context: cli.String("context"),
7876
Framework: cli.String("framework"),

0 commit comments

Comments
 (0)