Skip to content

Commit

Permalink
Enable tty by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Nov 29, 2024
1 parent 3ab702e commit ab1ae9b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 69 deletions.
32 changes: 9 additions & 23 deletions dev/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,25 +220,7 @@ Run with legacy oci-env, check the [Running oci-env integration tests](../../doc

### Debugging

#### Step 1 - Enable tty and stdin on the container you want to debug

For example, if you are debugging the `migrations` container, edit the migrations: service
on `aap.yaml` and find the lines.

```yaml
# uncomment below when debugging
# stdin_open: true
# tty: true
```

and remove the comment

```yaml
stdin_open: true
tty: true
```
#### Step 2 - Add the breakpoint
#### Step 1 - Add the breakpoint

Edit the file you want to debug and add a breakpoint

Expand All @@ -249,9 +231,9 @@ __import__("ipdb").set_trace()
> [!TIP]
> Replace if you are using a different debugger, however the images has only **pdb** and **ipdb** installed.
If you discover other ways of debugging, likle connecting dab protocol or vscode debugger, please update this file!
If you discover other ways of debugging, like connecting dap protocol or vscode debugger, please update this file!

#### Step 3- Now execute your stack or just the container you are trying to debug.
#### Step 2 - Now execute your stack or just the container you are trying to debug.

Example:

Expand All @@ -261,13 +243,17 @@ $ docker compose -f dev/compose/aap.yaml up migrations
# The container will keep running stopped on the breakpoint.
```

#### Step 4- Attach
#### Step 3 - Attach

```bash
$ docker compose -f dev/compose/insights.yaml attach migrations
$ docker compose -f dev/compose/aap.yaml attach migrations
ipdb>
```

> [!IMPORTANT]
> To detach from the container DO NOT use <kbd>Ctrl+c</kbd>,
> instead, use <kbd>Ctrl-p Ctrl-q</kbd>
---

**TBD**
Expand Down
24 changes: 9 additions & 15 deletions dev/compose/aap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ x-common-env: &common-env
# $ DEV_SOURCE_PATH="pulp_container:galaxy_ng" docker compose -f dev/compose/aap.yaml up
DEV_SOURCE_PATH:

# allow attaching to the running container
x-debugging: &debugging
stdin_open: true
tty: true

services:
base_img:
Expand Down Expand Up @@ -127,6 +131,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
set -e;
Expand All @@ -140,9 +145,6 @@ services:
touch /var/lib/pulp/.migrated;
"
# uncomment below when debugging
# stdin_open: true
# tty: true
api:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -163,16 +165,14 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api
"
# uncomment below when debugging
# stdin_open: true
# tty: true
content:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -193,16 +193,14 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content
"
# uncomment below when debugging
# stdin_open: true
# tty: true
worker:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -218,6 +216,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
Expand All @@ -228,9 +227,6 @@ services:
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-worker
"
# uncomment below when debugging
# stdin_open: true
# tty: true
manager:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -247,6 +243,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
Expand Down Expand Up @@ -287,9 +284,6 @@ services:
# Keep it running indefinitely to enable `docker compose -f ... exec manager /bin/bash`;
tail -f /dev/null
"
# uncomment below when debugging
# stdin_open: true
# tty: true
nginx:
image: "nginx:latest"
Expand Down
25 changes: 10 additions & 15 deletions dev/compose/community.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ x-common-env: &common-env
DEV_SOURCE_PATH:


# allow attaching to the running container
x-debugging: &debugging
stdin_open: true
tty: true

services:
base_img:
build:
Expand Down Expand Up @@ -148,6 +153,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
set -e;
Expand All @@ -161,9 +167,6 @@ services:
touch /var/lib/pulp/.migrated;
"
# uncomment below when debugging
# stdin_open: true
# tty: true
api:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -184,15 +187,13 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api
"
# uncomment below when debugging
# stdin_open: true
# tty: true
content:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -213,15 +214,13 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content
"
# uncomment below when debugging
# stdin_open: true
# tty: true
worker:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -237,15 +236,13 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-worker
"
# uncomment below when debugging
# stdin_open: true
# tty: true
manager:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -262,6 +259,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
Expand All @@ -288,9 +286,6 @@ services:
# Keep it running indefinitely to enable `docker compose -f ... exec manager /bin/bash`;
tail -f /dev/null
"
# uncomment below when debugging
# stdin_open: true
# tty: true
nginx:
image: "nginx:latest"
Expand Down
26 changes: 10 additions & 16 deletions dev/compose/insights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ x-common-env: &common-env
# $ DEV_SOURCE_PATH="pulp_container:galaxy_ng" docker compose -f dev/compose/aap.yaml up
DEV_SOURCE_PATH:


# allow attaching to the running container
x-debugging: &debugging
stdin_open: true
tty: true

services:
base_img:
build:
Expand Down Expand Up @@ -127,6 +131,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
set -e;
Expand All @@ -140,9 +145,6 @@ services:
touch /var/lib/pulp/.migrated;
"
# uncomment below when debugging
# stdin_open: true
# tty: true
api:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -163,15 +165,13 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api
"
# uncomment below when debugging
# stdin_open: true
# tty: true
content:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -192,15 +192,13 @@ services:
- default
- service-mesh
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
/src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated;
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content
"
# uncomment below when debugging
# stdin_open: true
# tty: true
worker:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -216,6 +214,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
Expand All @@ -226,9 +225,6 @@ services:
/src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-worker
"
# uncomment below when debugging
# stdin_open: true
# tty: true
manager:
image: "localhost/galaxy_ng/galaxy_ng:dev"
Expand All @@ -245,6 +241,7 @@ services:
environment:
<<: *common-env
user: root
<<: *debugging
command: |
bash -c "
/src/galaxy_ng/dev/compose/bin/devinstall;
Expand Down Expand Up @@ -275,9 +272,6 @@ services:
# Keep it running indefinitely to enable `docker compose -f ... exec manager /bin/bash`;
tail -f /dev/null
"
# uncomment below when debugging
# stdin_open: true
# tty: true
nginx:
image: "nginx:latest"
Expand Down

0 comments on commit ab1ae9b

Please sign in to comment.