Skip to content

Commit 8afee3d

Browse files
authored
Fixes Registry Actions & Unable to encrypt connection: Unable to create server credentials Issue (#18)
- 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`
1 parent fbdbc79 commit 8afee3d

File tree

3 files changed

+59
-11
lines changed

3 files changed

+59
-11
lines changed

.github/workflows/registry-actions.yml

Lines changed: 13 additions & 7 deletions
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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,19 +352,38 @@ it away) and restart the Snap to get it restored.
352352

353353
#### Step-by-Step Guide
354354

355-
The first step is to pull the ghostscript-printer-app Docker image from Docker Hub.
355+
You can pull the `ghostscript-printer-app` Docker image from either the GitHub Container Registry or Docker Hub.
356+
357+
**From GitHub Container Registry** <br>
358+
To pull the image from the GitHub Container Registry, run the following command:
359+
```sh
360+
sudo docker pull ghcr.io/openprinting/ghostscript-printer-app:latest
361+
```
362+
363+
To run the container after pulling the image from the GitHub Container Registry, use:
364+
```sh
365+
sudo docker run -d \
366+
--name ghostscript-printer-app \
367+
--network host \
368+
-e PORT=<port> \
369+
ghcr.io/openprinting/ghostscript-printer-app:latest
370+
```
371+
372+
**From Docker Hub** <br>
373+
Alternatively, you can pull the image from Docker Hub, by running:
356374
```sh
357375
sudo docker pull openprinting/ghostscript-printer-app
358376
```
359377

360-
Run the following Docker command to run the ghostscript-printer-app image:
378+
To run the container after pulling the image from Docker Hub, use:
361379
```sh
362-
sudo docker run --rm -d \
380+
sudo docker run -d \
363381
--name ghostscript-printer-app \
364382
--network host \
365383
-e PORT=<port> \
366384
openprinting/ghostscript-printer-app:latest
367385
```
386+
368387
- `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.
369388
- **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.
370389
- 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.
@@ -408,7 +427,7 @@ Once the rock is built, you need to compile docker image from it.
408427
**Run the ghostscript-printer-app Docker Container**
409428

410429
```sh
411-
sudo docker run --rm -d \
430+
sudo docker run -d \
412431
--name ghostscript-printer-app \
413432
--network host \
414433
-e PORT=<port> \

scripts/start-server.sh

Lines changed: 23 additions & 0 deletions
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/ghostscript-printer-app directory exists
20+
STATE_DIR="/var/lib/ghostscript-printer-app"
21+
22+
if [ ! -d "$STATE_DIR" ]; then
23+
mkdir -p "$STATE_DIR"
24+
fi
25+
chmod 755 "$STATE_DIR"
26+
27+
# Ensure ghostscript-printer-app.state file exists
28+
STATE_FILE="$STATE_DIR/ghostscript-printer-app.state"
29+
if [ ! -f "$STATE_FILE" ]; then
30+
touch "$STATE_FILE"
31+
fi
32+
chmod 755 "$STATE_FILE"
33+
34+
# Start the ghostscript-printer-app server
1235
ghostscript-printer-app -o log-file=/ghostscript-printer-app.log ${PORT:+-o server-port=$PORT} server

0 commit comments

Comments
 (0)