Skip to content

Commit 34b7cfd

Browse files
committed
Added run_container.sh script, formatted README
1 parent c375d0b commit 34b7cfd

3 files changed

Lines changed: 111 additions & 40 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ cypress/videos/*
1010
dist/
1111
node_modules/
1212
npm-debug.log*
13+
tests/settings

README.md

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,37 @@ A community driven UI for [Pulp](https://pulpproject.org/).
44

55
## How to run
66

7-
### backend
7+
### Backend
88

9-
You can follow the [pulp-oci-images quickstart](https://pulpproject.org/pulp-oci-images/docs/admin/tutorials/quickstart/),
10-
TLDR:
9+
The `tests/run_container.sh` script is provided and allows you to run a command with a [Pulp in one](https://pulpproject.org/pulp-in-one-container/) container active.
10+
It requires Docker or Podman to be installed.
11+
The default credentials are:
12+
Username: admin
13+
Password: password
1114

12-
#### setup:
13-
14-
```sh
15-
mkdir -p ~/pulp-backend-oci/{settings/certs,pulp_storage,pgsql,containers}
16-
cd ~/pulp-backend-oci/
17-
echo "
18-
CONTENT_ORIGIN='http://$(hostname):8080'
19-
ANSIBLE_API_HOSTNAME='http://$(hostname):8080'
20-
ANSIBLE_CONTENT_HOSTNAME='http://$(hostname):8080/pulp/content'
21-
" >> settings/settings.py
2215
```
23-
24-
#### run:
25-
26-
```sh
27-
cd ~/pulp-backend-oci/
28-
podman run --publish 8080:80 \
29-
--replace --name pulp \
30-
--volume "$(pwd)/settings":/etc/pulp \
31-
--volume "$(pwd)/pulp_storage":/var/lib/pulp \
32-
--volume "$(pwd)/pgsql":/var/lib/pgsql \
33-
--volume "$(pwd)/containers":/var/lib/containers \
34-
docker.io/pulp/pulp
16+
./tests/run_container sleep inf
3517
```
3618

37-
#### check:
19+
#### Check:
3820

3921
```sh
4022
curl localhost:8080/pulp/api/v3/status/ | jq
4123
```
4224

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

45-
#### change password:
46-
47-
```sh
48-
podman exec -it pulp pulpcore-manager reset-admin-password --password admin
49-
```
50-
```sh
51-
docker exec -it compose-pulp_api-1 pulpcore-manager reset-admin-password --password admin
52-
```
53-
54-
#### configure `pulp-cli`:
27+
#### Configure `pulp-cli`:
5528

5629
```sh
5730
pip install pulp-cli[pygments]
58-
pulp config create --username admin --base-url http://localhost:8080 --password admin
31+
pulp config create --username admin --base-url http://localhost:8080 --password password
5932

6033
pulp --help
6134
pulp user list
6235
```
6336

64-
### frontend
37+
### Frontend
6538

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

@@ -72,12 +45,12 @@ npm run start
7245

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

75-
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.
48+
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.
7649

7750

7851
## Misc
7952

80-
### post-build configuration
53+
### Post-build configuration
8154

8255
The UI builds produced by `npm run build` can be further configured by serving a `/pulp-ui-config.json` alongside the built UI.
8356
(Note it has to be mapped at `/`, not just wherever `index.html` is served from.)

tests/run_container.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/sh
2+
3+
# This file is shared between some projects please keep all copies in sync
4+
# Known places:
5+
# - https://github.com/pulp/pulp-cli/blob/main/.ci/run_container.sh
6+
# - https://github.com/pulp/pulp-cli-deb/blob/main/.ci/run_container.sh
7+
# - https://github.com/pulp/pulp-cli-ostree/blob/main/.ci/run_container.sh
8+
# - https://github.com/pulp/squeezer/blob/develop/tests/run_container.sh
9+
# - https://github.com/pulp/pulp-ui/blob/main/tests/run_container.sh
10+
11+
set -eu
12+
13+
BASEPATH="$(dirname "$(readlink -f "$0")")"
14+
export BASEPATH
15+
16+
if [ -z "${CONTAINER_RUNTIME:+x}" ]
17+
then
18+
if ls /usr/bin/podman
19+
then
20+
CONTAINER_RUNTIME=podman
21+
else
22+
CONTAINER_RUNTIME=docker
23+
fi
24+
fi
25+
export CONTAINER_RUNTIME
26+
27+
if [ -z "${KEEP_CONTAINER:+x}" ]
28+
then
29+
RM="yes"
30+
else
31+
RM=""
32+
fi
33+
34+
IMAGE_TAG="${IMAGE_TAG:-latest}"
35+
FROM_TAG="${FROM_TAG:-latest}"
36+
37+
if [ "${CONTAINER_FILE:+x}" ]
38+
then
39+
IMAGE_TAG="ephemeral-build"
40+
"${CONTAINER_RUNTIME}" build --file "${BASEPATH}/assets/${CONTAINER_FILE}" --build-arg FROM_TAG="${FROM_TAG}" --tag ghcr.io/pulp/pulp:"${IMAGE_TAG}" .
41+
fi
42+
43+
if [ "$(getenforce)" = "Enforcing" ]; then
44+
SELINUX="yes"
45+
else
46+
SELINUX=""
47+
fi;
48+
49+
"${CONTAINER_RUNTIME}" \
50+
run ${RM:+--rm} \
51+
--env S6_KEEP_ENV=1 \
52+
${PULP_API_ROOT:+--env PULP_API_ROOT} \
53+
--detach \
54+
--name "pulp-ephemeral" \
55+
--volume "${BASEPATH}/settings:/etc/pulp${SELINUX:+:Z}" \
56+
--publish "8080:80" \
57+
--network "bridge" \
58+
"ghcr.io/pulp/pulp:${IMAGE_TAG}"
59+
60+
# shellcheck disable=SC2064
61+
trap "${CONTAINER_RUNTIME} stop pulp-ephemeral" EXIT
62+
# shellcheck disable=SC2064
63+
trap "${CONTAINER_RUNTIME} stop pulp-ephemeral" INT
64+
65+
echo "Wait for pulp to start."
66+
for counter in $(seq 40 -1 0)
67+
do
68+
if [ "$counter" = "0" ]
69+
then
70+
echo "FAIL."
71+
"${CONTAINER_RUNTIME}" images
72+
"${CONTAINER_RUNTIME}" ps -a
73+
"${CONTAINER_RUNTIME}" logs "pulp-ephemeral"
74+
exit 1
75+
fi
76+
77+
sleep 3
78+
if curl --fail "http://localhost:8080${PULP_API_ROOT:-/pulp/}api/v3/status/" > /dev/null 2>&1
79+
then
80+
echo "SUCCESS."
81+
break
82+
fi
83+
echo "."
84+
done
85+
86+
# show pulpcore/plugin versions we're using
87+
curl -s "http://localhost:8080${PULP_API_ROOT:-/pulp/}api/v3/status/" | jq '.versions|map({key: .component, value: .version})|from_entries'
88+
89+
# Set admin password
90+
"${CONTAINER_RUNTIME}" exec "pulp-ephemeral" pulpcore-manager reset-admin-password --password password
91+
92+
if [ -d "${BASEPATH}/container_setup.d/" ]
93+
then
94+
run-parts --regex '^[0-9]+-[-_[:alnum:]]*\.sh$' "${BASEPATH}/container_setup.d/"
95+
fi
96+
97+
PULP_LOGGING="${CONTAINER_RUNTIME}" "$@"

0 commit comments

Comments
 (0)