Skip to content

Suggested Dockerfile #54

@ringerc

Description

@ringerc

Thanks for the handy tool.

Please consider shipping a Dockerfile that can be used to bundle up an unprivileged container image with this tool, so users don't have to trust the sprawl of npm dependencies with access to the rest of their user accounts.

Here's one I wrote which might be useful as a starting point or for others.

FROM node:20-alpine3.16
RUN adduser -D pd
USER pd
RUN mkdir /home/pd/pd-cli
WORKDIR /home/pd/pd-cli
RUN npm install pagerduty-cli
VOLUME /home/pd/.config/pagerduty-cli
RUN mkdir -p /home/pd/.config/pagerduty-cli && chown pd:pd /home/pd/.config/pagerduty-cli
ENTRYPOINT ["npm", "exec", "--", "pd"]

# run with e.g.
#   docker run -it --rm --mount type=volume,source=pd-cli,destination=/home/pd/.config/pagerduty-cli pd-cli
#
# you will need to use the "auth:set" command the first time, and supply an api token
# created with your PD account under My Account -> User Settings -> API Access
# see https://support.pagerduty.com/docs/api-access-keys#section-generate-a-user-token-rest-api-key

Build with docker buildx build -t pd-cli . within an empty directory containing only the Dockerfile.

I then put this wrapper script in $HOME/.local/bin/pd - you can put it anywhere convenient on your PATH:

#!/bin/bash
docker run -it --rm --mount type=volume,source=pd-cli,destination=/home/pd/.config/pagerduty-cli pd-cli "$@"

A bind-mount could be used to bind the configdir for the CLI from the user's own homedir instead of using a docker volume, but using a volume was more convenient from an unprivileged access-control point of view.

On first use, run

pd auth:set

and enter a PD API token created with your PD account under My Account -> User Settings -> API Access. Watch out, the output will be echoed to the terminal.

Subsequent runs will remember it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions