Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cypress/videos/*
dist/
node_modules/
npm-debug.log*
tests/settings/certs/
36 changes: 27 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ A community driven UI for [Pulp](https://pulpproject.org/).

## How to run

### backend
### Backend

You can follow the [pulp-oci-images quickstart](https://pulpproject.org/pulp-oci-images/docs/admin/tutorials/quickstart/),
TLDR:

#### setup:
#### Setup:

```sh
mkdir -p ~/pulp-backend-oci/{settings/certs,pulp_storage,pgsql,containers}
Expand All @@ -21,7 +21,7 @@ ANSIBLE_CONTENT_HOSTNAME='http://$(hostname):8080/pulp/content'
" >> settings/settings.py
```

#### run:
#### Run:

```sh
cd ~/pulp-backend-oci/
Expand All @@ -34,15 +34,15 @@ podman run --publish 8080:80 \
docker.io/pulp/pulp
```

#### check:
#### Check:

```sh
curl localhost:8080/pulp/api/v3/status/ | jq
```

or open http://localhost:8080/pulp/api/v3/status/

#### change password:
#### Change password:

```sh
podman exec -it pulp pulpcore-manager reset-admin-password --password admin
Expand All @@ -51,7 +51,7 @@ podman exec -it pulp pulpcore-manager reset-admin-password --password admin
docker exec -it compose-pulp_api-1 pulpcore-manager reset-admin-password --password admin
```

#### configure `pulp-cli`:
#### Configure `pulp-cli`:

```sh
pip install pulp-cli[pygments]
Expand All @@ -61,7 +61,25 @@ pulp --help
pulp user list
```

### frontend
### Setup (run_container.sh script)

The `tests/run_container.sh` script is provided and allows you to run a command with a [Pulp OCI-image](https://pulpproject.org/pulp-oci-images/docs/admin/tutorials/quickstart/) container running.

It requires Docker or Podman to be installed.

The default credentials are:
* Username: admin
* Password: admin

```
./tests/run_container sleep inf
```

The following optional environment variable is availble to be set:

* `IMAGE_TAG`: Change the Pulp OCI image tage to use, defaults to `latest`

### Frontend

You can clone the frontend from https://github.com/pulp/pulp-ui .

Expand All @@ -72,12 +90,12 @@ npm run start

and open http://localhost:8002/ :tada: :)

If your API listens elsewhere, you can use `API_PROXY=http://elsewhere:12345 npm run start` instead. Do note that the server at `elsewhere` has to be configured to allow CORS requests for `localhost` (where UI actually listens); using something like `changeOrigin` is out of scope for pulp-ui, and breaks pulp API URLs (because the domains are based on the Origin header). Do NOT use webpack proxy in production.
If your PULP API listens elsewhere, you can use `API_PROXY=http://elsewhere:12345 npm run start` instead. Do note that the server at `elsewhere` has to be configured to allow CORS requests for `localhost` (where UI actually listens); using something like `changeOrigin` is out of scope for pulp-ui, and breaks pulp API URLs (because the domains are based on the Origin header). Do NOT use webpack proxy in production.


## Misc

### post-build configuration
### Post-build configuration

The UI builds produced by `npm run build` can be further configured by serving a `/pulp-ui-config.json` alongside the built UI.
(Note it has to be mapped at `/`, not just wherever `index.html` is served from.)
Expand Down
85 changes: 85 additions & 0 deletions tests/run_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# This script was originally taken from the https://github.com/pulp/squeezer repository and adapted for pulp-ui

set -eu

BASEPATH="$(dirname "$(readlink -f "$0")")"
export BASEPATH

if [ -z "${CONTAINER_RUNTIME:+x}" ]
then
if command -v podman > /dev/null 2>&1
then
CONTAINER_RUNTIME=podman
else
CONTAINER_RUNTIME=docker
fi
fi
export CONTAINER_RUNTIME

if [ -z "${KEEP_CONTAINER:+x}" ]
then
RM="yes"
else
RM=""
fi

IMAGE_TAG="${IMAGE_TAG:-latest}"

# Check if getenforce is available and set SELINUX accordingly
if command -v getenforce > /dev/null 2>&1
then
if [ "$(getenforce)" = "Enforcing" ]
then
SELINUX="yes"
else
SELINUX=""
fi
else
SELINUX=""
fi

"${CONTAINER_RUNTIME}" \
run ${RM:+--rm} \
--env S6_KEEP_ENV=1 \
--detach \
--name "pulp-ephemeral" \
--volume "${BASEPATH}/settings:/etc/pulp${SELINUX:+:Z}" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and here, there is no pulp-ui/tests/settings)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my mistake, I've added settings.py and changed .gitignore to exclude the tests/settings/certs/ directory.

--publish "8080:80" \
--network "bridge" \
"docker.io/pulp/pulp:${IMAGE_TAG}"

# shellcheck disable=SC2064
trap "${CONTAINER_RUNTIME} stop pulp-ephemeral" EXIT
# shellcheck disable=SC2064
trap "${CONTAINER_RUNTIME} stop pulp-ephemeral" INT

echo "Wait for pulp to start."
for counter in $(seq 40 -1 0)
do
if [ "$counter" = "0" ]
then
echo "FAIL."
"${CONTAINER_RUNTIME}" images
"${CONTAINER_RUNTIME}" ps -a
"${CONTAINER_RUNTIME}" logs "pulp-ephemeral"
exit 1
fi

sleep 3
if curl --fail "http://localhost:8080/pulp/api/v3/status/" > /dev/null 2>&1
then
echo "SUCCESS."
break
fi
echo "."
done

# Show pulpcore/plugin versions we're using
curl -s "http://localhost:8080/pulp/api/v3/status/" | jq '.versions|map({key: .component, value: .version})|from_entries'

# Set admin password
"${CONTAINER_RUNTIME}" exec "pulp-ephemeral" pulpcore-manager reset-admin-password --password admin

PULP_LOGGING="${CONTAINER_RUNTIME}" "$@"
Copy link
Collaborator

@himdel himdel Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PULP_LOGGING="${CONTAINER_RUNTIME}" "$@"
echo Press ^C to stop the container 1>&2
sleep inf

and we don't need to document any params for it :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think of this. But one way this script can be use is running it with test software, Squeezer (ansible module) does it like this:

./tests/run_container.sh make livetest

This allows a user to start a pulp oci container, run tests against it and automatically have it remove itself when complete.

This script could be used in the same way for this repository in the future.

5 changes: 5 additions & 0 deletions tests/settings/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONTENT_ORIGIN = "http://localhost:8080/"
ALLOWED_EXPORT_PATHS = ["/tmp"]
CACHE_ENABLED = True
REDIS_HOST = "localhost"
REDIS_PORT = 6379