Skip to content

Commit 6b10f32

Browse files
authored
Fixes Registry Actions & Unable to encrypt connection: Unable to create server credentials Issue (#22)
- Enhance start-server script to create missing directories and files (`CUPS_SERVERROOT`, `STATE_DIR`, `STATE_FILE`) with appropriate permissions - Update README with OCI image instructions for GitHub Container Registry - Fix `registry-actions.yml` - Remove `--rm` instruction from README
1 parent f13b641 commit 6b10f32

File tree

3 files changed

+59
-11
lines changed

3 files changed

+59
-11
lines changed

.github/workflows/registry-actions.yml

+13-7
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,28 @@ jobs:
7373
uses: docker/login-action@v3.2.0
7474
with:
7575
registry: ghcr.io
76-
username: ${{ github.actor }}
76+
username: ${{ github.repository_owner }}
7777
password: ${{ secrets.GITHUB_TOKEN }}
7878

7979
- name: Build and Push Docker Image (Edge & Latest Channel)
8080
if: github.event.inputs.workflow_choice == 'edge' || github.event.inputs.workflow_choice == 'both' || github.event_name == 'push' || github.event_name == 'workflow_run'
8181
env:
8282
USERNAME: ${{ secrets.DOCKER_USERNAME }}
83+
ORG: ${{ github.repository_owner }}
8384
run: |
8485
IMAGE="$(yq '.name' rockcraft.yaml)"
8586
VERSION="$(yq '.version' rockcraft.yaml)"
8687
ROCK="$(ls *.rock | tail -n 1)"
87-
sudo rockcraft.skopeo --insecure-policy copy oci-archive:"${ROCK}" docker-daemon:"${USERNAME}/${IMAGE}:${VERSION}-edge"
88+
ORG_NAME=$(echo "${ORG}" | tr '[:upper:]' '[:lower:]')
89+
sudo rockcraft.skopeo --insecure-policy copy oci-archive:"${ROCK}" docker-daemon:"${ORG_NAME}/${IMAGE}:${VERSION}-edge"
8890
# Push to Docker Hub
91+
# docker tag ${ORG_NAME}/${IMAGE}:${VERSION}-edge ${USERNAME}:${VERSION}-edge
8992
# docker push ${USERNAME}/${IMAGE}:${VERSION}-edge
9093
# docker tag ${USERNAME}/${IMAGE}:${VERSION}-edge ${USERNAME}/${IMAGE}:latest
9194
# docker push ${USERNAME}/${IMAGE}:latest
9295
# Push to GitHub Packages
93-
GITHUB_IMAGE="ghcr.io/${{ github.repository_owner }}/${IMAGE}"
94-
docker tag ${USERNAME}/${IMAGE}:${VERSION}-edge ${GITHUB_IMAGE}:${VERSION}-edge
96+
GITHUB_IMAGE="ghcr.io/${ORG_NAME}/${IMAGE}"
97+
docker tag ${ORG_NAME}/${IMAGE}:${VERSION}-edge ${GITHUB_IMAGE}:${VERSION}-edge
9598
docker push ${GITHUB_IMAGE}:${VERSION}-edge
9699
docker tag ${GITHUB_IMAGE}:${VERSION}-edge ${GITHUB_IMAGE}:latest
97100
docker push ${GITHUB_IMAGE}:latest
@@ -100,14 +103,17 @@ jobs:
100103
if: github.event.inputs.workflow_choice == 'stable' || github.event.inputs.workflow_choice == 'both'
101104
env:
102105
USERNAME: ${{ secrets.DOCKER_USERNAME }}
106+
ORG: ${{ github.repository_owner }}
103107
run: |
104108
IMAGE="$(yq '.name' rockcraft.yaml)"
105109
VERSION="$(yq '.version' rockcraft.yaml)"
106110
ROCK="$(ls *.rock | tail -n 1)"
107-
sudo rockcraft.skopeo --insecure-policy copy oci-archive:"${ROCK}" docker-daemon:"${USERNAME}/${IMAGE}:${VERSION}-stable"
111+
ORG_NAME=$(echo "${ORG}" | tr '[:upper:]' '[:lower:]')
112+
sudo rockcraft.skopeo --insecure-policy copy oci-archive:"${ROCK}" docker-daemon:"${ORG_NAME}/${IMAGE}:${VERSION}-stable"
108113
# Push to Docker Hub
114+
# docker tag ${ORG_NAME}/${IMAGE}:${VERSION}-stable ${USERNAME}:${VERSION}-stable
109115
# docker push ${USERNAME}/${IMAGE}:${VERSION}-stable
110116
# Push to GitHub Packages
111-
GITHUB_IMAGE="ghcr.io/${{ github.repository_owner }}/${IMAGE}"
112-
docker tag ${USERNAME}/${IMAGE}:${VERSION}-stable ${GITHUB_IMAGE}:${VERSION}-stable
117+
GITHUB_IMAGE="ghcr.io/${ORG_NAME}/${IMAGE}"
118+
docker tag ${ORG_NAME}/${IMAGE}:${VERSION}-stable ${GITHUB_IMAGE}:${VERSION}-stable
113119
docker push ${GITHUB_IMAGE}:${VERSION}-stable

README.md

+23-4
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,38 @@ file for configuring SNMP network printer discovery.
258258

259259
#### Step-by-Step Guide
260260

261-
The first step is to pull the hplip-printer-app Docker image from Docker Hub.
261+
You can pull the `hplip-printer-app` Docker image from either the GitHub Container Registry or Docker Hub.
262+
263+
**From GitHub Container Registry** <br>
264+
To pull the image from the GitHub Container Registry, run the following command:
265+
```sh
266+
sudo docker pull ghcr.io/openprinting/hplip-printer-app:latest
267+
```
268+
269+
To run the container after pulling the image from the GitHub Container Registry, use:
270+
```sh
271+
sudo docker run -d \
272+
--name hplip-printer-app \
273+
--network host \
274+
-e PORT=<port> \
275+
ghcr.io/openprinting/hplip-printer-app:latest
276+
```
277+
278+
**From Docker Hub** <br>
279+
Alternatively, you can pull the image from Docker Hub, by running:
262280
```sh
263281
sudo docker pull openprinting/hplip-printer-app
264282
```
265283

266-
Run the following Docker command to run the hplip-printer-app image:
284+
To run the container after pulling the image from Docker Hub, use:
267285
```sh
268-
sudo docker run --rm -d \
286+
sudo docker run -d \
269287
--name hplip-printer-app \
270288
--network host \
271289
-e PORT=<port> \
272290
openprinting/hplip-printer-app:latest
273291
```
292+
274293
- `PORT` is an optional environment variable used to start the printer-app on a specified port. If not provided, it will start on the default port 8000 or, if port 8000 is busy, on 8001 and so on.
275294
- **The container must be started in `--network host` mode** to allow the Printer-Application instance inside the container to access and discover printers available in the local network where the host system is in.
276295
- Alternatively using the internal network of the Docker instance (`-p <port>:8000` instead of `--network host -e PORT=<port>`) only gives access to local printers running on the host system itself.
@@ -314,7 +333,7 @@ Once the rock is built, you need to compile docker image from it.
314333
**Run the hplip-printer-app Docker Container**
315334

316335
```sh
317-
sudo docker run --rm -d \
336+
sudo docker run -d \
318337
--name hplip-printer-app \
319338
--network host \
320339
-e PORT=<port> \

scripts/start-server.sh

+23
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,27 @@ if [ -n "${PORT:-}" ]; then
99
fi
1010
fi
1111

12+
# Ensure the /etc/cups/ssl directory exists with proper permissions
13+
CUPS_SERVERROOT="/etc/cups/ssl"
14+
if [ ! -d "$CUPS_SERVERROOT" ]; then
15+
mkdir -p "$CUPS_SERVERROOT"
16+
fi
17+
chmod 755 "$CUPS_SERVERROOT"
18+
19+
# Ensure /var/lib/hplip-printer-app directory exists
20+
STATE_DIR="/var/lib/hplip-printer-app"
21+
22+
if [ ! -d "$STATE_DIR" ]; then
23+
mkdir -p "$STATE_DIR"
24+
fi
25+
chmod 755 "$STATE_DIR"
26+
27+
# Ensure hplip-printer-app.state file exists
28+
STATE_FILE="$STATE_DIR/hplip-printer-app.state"
29+
if [ ! -f "$STATE_FILE" ]; then
30+
touch "$STATE_FILE"
31+
fi
32+
chmod 755 "$STATE_FILE"
33+
34+
# Start the hplip-printer-app server
1235
hplip-printer-app -o log-file=/hplip-printer-app.log ${PORT:+-o server-port=$PORT} server

0 commit comments

Comments
 (0)