|
| 1 | +# Galaxy Simplified Compose Stack |
| 2 | + |
| 3 | +Profiles: |
| 4 | + |
| 5 | +- `standalone` - Run galaxy_ng for integration with Ansible Automation Platform |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +- `docker compose` version `>=2` |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +Pick a profile as needed and on the root of `galaxy_ng` repository. |
| 14 | + |
| 15 | +> Examples assumes `standalone` as the profile, change as needed. |
| 16 | +
|
| 17 | +Build images |
| 18 | +```bash |
| 19 | +docker compose -f dev/compose/standalone.yaml build |
| 20 | +``` |
| 21 | + |
| 22 | +Run the stack |
| 23 | +```bash |
| 24 | +docker compose -f dev/compose/standalone.yaml up |
| 25 | +# optionally pass `-d` to release the terminal |
| 26 | +``` |
| 27 | + |
| 28 | +Exec commands on the `manager` service |
| 29 | + |
| 30 | +Bash |
| 31 | +```console |
| 32 | +$ docker compose -f dev/compose/standalone.yaml exec manager /bin/bash |
| 33 | +bash-4.4# |
| 34 | +``` |
| 35 | +Django Admin |
| 36 | +```console |
| 37 | +$ docker compose -f dev/compose/standalone.yaml exec manager pulpcore-manager |
| 38 | +Type 'pulpcore-manager help <subcommand>' for help on a specific subcommand. |
| 39 | + |
| 40 | +Available subcommands: |
| 41 | + |
| 42 | +[app] |
| 43 | + add-signing-service |
| 44 | + analyze-publication |
| 45 | +... |
| 46 | +``` |
| 47 | + |
| 48 | +Settings |
| 49 | +```console |
| 50 | +$ docker compose -f dev/compose/standalone.yaml exec manager dynaconf get DATABASES | python -m json.tool |
| 51 | +{ |
| 52 | + "default": { |
| 53 | + "ENGINE": "django.db.backends.postgresql", |
| 54 | + "HOST": "postgres", |
| 55 | + "NAME": "galaxy_ng", |
| 56 | + "PASSWORD": "galaxy_ng", |
| 57 | + "PORT": 5432, |
| 58 | + "USER": "galaxy_ng" |
| 59 | + } |
| 60 | +} |
| 61 | +``` |
| 62 | +```console |
| 63 | +$ docker compose -f dev/compose/standalone.yaml exec manager dynaconf list |
| 64 | +CONTENT_ORIGIN<str> 'https://localhost' |
| 65 | +CACHE_ENABLED<bool> False |
| 66 | +CACHE_SETTINGS<dict> {'EXPIRES_TTL': 600} |
| 67 | +ALLOWED_CONTENT_CHECKSUMS<list> ['sha224', 'sha256', 'sha384', 'sha512'] |
| 68 | +... |
| 69 | +``` |
| 70 | + |
| 71 | +Stopping |
| 72 | +```console |
| 73 | +$ docker compose -f dev/compose/standalone.yaml down |
| 74 | +# add -v to stop and remove volumes |
| 75 | +``` |
| 76 | + |
| 77 | +> [!TIP] |
| 78 | +> Stop with Ctrl + C if running without `-d` and then execute the `down` command. |
| 79 | +
|
| 80 | +## API Access |
| 81 | + |
| 82 | +Galaxy API is available on: |
| 83 | + |
| 84 | +[http://localhost:5001/api/galaxy/v3/swagger-ui/](http://localhost:5001/api/galaxy/v3/swagger-ui/) |
| 85 | + |
| 86 | +AAP UI and API will be available only if started separately on: |
| 87 | + |
| 88 | +[https://localhost](https://localhost) |
| 89 | + |
| 90 | + |
| 91 | +## Running UI for standalone development |
| 92 | + |
| 93 | +Ansible Hub UI can be started separately as a standalone `npm` run. |
| 94 | + |
| 95 | +```console |
| 96 | +# Assuming galaxy_ng is running on standalone compose. |
| 97 | + |
| 98 | +$ git clone https://github.com/ansible/ansible-hub-ui ~/projects/ansible-hub-ui |
| 99 | +$ git clone https://github.com/ansible/galaxy_ng ~/projects/galaxy_ng |
| 100 | +``` |
| 101 | +Open 2 terminals: |
| 102 | + |
| 103 | +On the first terminal: |
| 104 | + |
| 105 | +```console |
| 106 | +$ cd galaxy_ng |
| 107 | +$ docker compose -f dev/compose/standalone.yaml up |
| 108 | +``` |
| 109 | + |
| 110 | +On the second terminal: |
| 111 | + |
| 112 | +```console |
| 113 | +cd ansible-hub-ui |
| 114 | +npm install |
| 115 | +npm run start-standalone |
| 116 | +``` |
| 117 | + |
| 118 | +UI will be available on http://localhost:8002 and API on http://localhost:5001 |
| 119 | + |
| 120 | + |
| 121 | +## Auto Reload and Local Checkouts |
| 122 | + |
| 123 | +To have the services `api`, `worker` and `content` to automatically reload when |
| 124 | +source code changes it is required to set which paths the `reloader` must watch for changes. |
| 125 | + |
| 126 | +Set the variable `DEV_SOURCE_PATH` with the packages you want to add to the reloader list. |
| 127 | + |
| 128 | +Those repositories must be local checkouts located on the same level of the `galaxy_ng` repository. |
| 129 | + |
| 130 | +Example: |
| 131 | + |
| 132 | +Get the repositories locally in the same root path. |
| 133 | +```console |
| 134 | +$ git clone https://github.com/dynaconf/dynaconf ~/projects/dynaconf |
| 135 | +$ git clone https://github.com/pulp/pulp_ansible ~/projects/pulp_ansible |
| 136 | +$ git clone https://github.com/ansible/galaxy_ng ~/projects/galaxy_ng |
| 137 | +``` |
| 138 | + |
| 139 | +> **IMPORTANT** Ensure all the repos are checked out to compatible branches. |
| 140 | +> for example. you may be on galaxy_ng:master and reading `setup.py` you |
| 141 | +> see that it requires `pulp_ansible>2.10,<3` then ensure you checkout `pulp_ansible` |
| 142 | +> to a compatible branch. |
| 143 | +
|
| 144 | +Start the compose setting the desired editable paths. |
| 145 | + |
| 146 | +```console |
| 147 | +$ cd ~/projects/galaxy_ng |
| 148 | +$ export DEV_SOURCE_PATH="dynaconf:pulp_ansible:galaxy_ng" |
| 149 | +$ docker compose -f dev/compose/standalone.yaml up --build |
| 150 | +``` |
| 151 | + |
| 152 | +Optionally it can be informed in a single line: |
| 153 | + |
| 154 | +```console |
| 155 | +$ DEV_SOURCE_PATH="dynaconf:pulp_ansible:galaxy_ng" docker compose -f dev/compose/app.yaml up --build |
| 156 | +``` |
| 157 | + |
| 158 | +> [!NOTE] |
| 159 | +> if passing on the call line, remember to repass the same variable every time you interact with |
| 160 | +>`docker compose` using the `run` command, usually `exec,logs,stats` doesn't require, but commands |
| 161 | +> that starts the service container from scratch needs the variables. |
| 162 | +
|
| 163 | +Now when changes are detected on `.py` and `.yaml` files on any of the `DEV_SOURCE_PATH` |
| 164 | +directories it will trigger reload of `api`, `worker`, and `content` services. |
| 165 | + |
| 166 | + |
| 167 | +## Troubleshooting |
| 168 | + |
| 169 | +### VersionConflict error |
| 170 | + |
| 171 | +Example: |
| 172 | +```bash |
| 173 | +api-1 | raise VersionConflict(dist, req).with_context(dependent_req) |
| 174 | +api-1 | pkg_resources.VersionConflict: (pkg_foo 3.2.6 (/venv/lib/python3.11/site-packages), Requirement.parse('pkg_foo<3.1.13,>=3.1.12')) |
| 175 | +``` |
| 176 | + |
| 177 | +Solution 1: |
| 178 | +Clean up local build files: |
| 179 | + |
| 180 | +```bash |
| 181 | +cd ~/projects/galaxy_ng |
| 182 | +rm -rf .eggs |
| 183 | +rm -rf build |
| 184 | +rm -rf galaxy_ng.egg-info |
| 185 | +``` |
| 186 | + |
| 187 | +Solution 2: |
| 188 | + |
| 189 | +- Ensure `LOCK_REQUIREMENTS` is set to `0` |
| 190 | +- Ensure all your local checkouts are checked out to compatible branches |
| 191 | + |
| 192 | +### LLB definition error |
| 193 | + |
| 194 | +```bash |
| 195 | +failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head "http://localhost/v2/galaxy_ng/galaxy_ng/manifests/base": dial tcp [::1]:80: connect: connection refused |
| 196 | +``` |
| 197 | + |
| 198 | +Solution |
| 199 | + |
| 200 | +```bash |
| 201 | +export DOCKER_BUILDKIT=0 |
| 202 | +export COMPOSE_DOCKER_CLI_BUILD=0 |
| 203 | +``` |
| 204 | + |
| 205 | +## Tests |
| 206 | + |
| 207 | +### Unit tests |
| 208 | +Run unit tests with docker compose [Running unit tests](../../galaxy_ng//tests/unit/README.md) |
| 209 | + |
| 210 | +### Integration tests |
| 211 | +Run integration tests with docker compose, check the [Running integration tests](../../galaxy_ng/tests/integration/README.md) |
| 212 | + |
| 213 | +Run with legacy oci-env, check the [Running oci-env integration tests](../../docs/dev/integration_tests.md) |
| 214 | + |
| 215 | +## Tips and Tricks. |
| 216 | + |
| 217 | +--- |
| 218 | + |
| 219 | +### Debugging |
| 220 | + |
| 221 | +#### Step 1 - Add the breakpoint |
| 222 | + |
| 223 | +Edit the file you want to debug and add a breakpoint |
| 224 | + |
| 225 | +```python |
| 226 | +__import__("ipdb").set_trace() |
| 227 | +``` |
| 228 | + |
| 229 | +> [!TIP] |
| 230 | +> Replace if you are using a different debugger, however the images has only **pdb** and **ipdb** installed. |
| 231 | +
|
| 232 | +If you discover other ways of debugging, like connecting dap protocol or vscode debugger, please update this file! |
| 233 | + |
| 234 | +#### Step 2 - Now execute your stack or just the container you are trying to debug. |
| 235 | + |
| 236 | +Example: |
| 237 | + |
| 238 | +```bash |
| 239 | +$ export DEV_SOURCE_PATH=galaxy_ng |
| 240 | +$ docker compose -f dev/compose/standalone.yaml up migrations |
| 241 | +# The container will keep running stopped on the breakpoint. |
| 242 | +``` |
| 243 | + |
| 244 | +#### Step 3 - Attach |
| 245 | + |
| 246 | +```bash |
| 247 | +$ docker compose -f dev/compose/standalone.yaml attach migrations |
| 248 | +ipdb> |
| 249 | +``` |
| 250 | + |
| 251 | +> [!IMPORTANT] |
| 252 | +> To detach from the container DO NOT use <kbd>Ctrl+c</kbd>, |
| 253 | +> instead, use <kbd>Ctrl-p Ctrl-q</kbd> |
| 254 | +
|
| 255 | +--- |
| 256 | + |
| 257 | +**TBD** |
| 258 | + |
| 259 | +### Connecting to Database |
| 260 | + |
| 261 | +### Dumping and restoring the database |
| 262 | + |
| 263 | +### Populating testing data |
0 commit comments