Skip to content

Commit d0bcd1b

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

File tree

3 files changed

+110
-40
lines changed

3 files changed

+110
-40
lines changed

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

0 commit comments

Comments
 (0)