Sign inSign up

jfxs/prettier

By jfxs

•Updated 4 days ago

A Node.js Docker image with Prettier

Image
0

138

jfxs/prettier repository overview

⁠Prettier

Software License Pipeline Status

A Node.js⁠ Docker image with Prettier⁠:

  • lightweight image based on a debian-slim, with git and Task⁠,
  • non-root container user (uid 1000) with support of arbitrary UIDs (OpenShift, docker run --user),
  • multiarch with support of amd64 and arm64,
  • automatically updated: Renovate tracks the Prettier, Task and base image versions and opens the merge requests,
  • image signed with Cosign⁠,
  • a software bill of materials (SBOM) attestation added using Syft⁠,
  • available on Docker Hub and Quay.io.

GitLab The main repository.

Docker Hub The Docker Hub registry.

Quay.io The Quay.io registry.

⁠Running Prettier in local

The working directory of the image is /work. There is no prettier entrypoint (the entrypoint only passes the command through): the command is explicit.

Check the formatting (read-only):

docker run --rm -v $(pwd):/work jfxs/prettier prettier --check .
⁠Writing files (--write)

The container does not run as root (uid 1000), so it can only modify files it is allowed to write. To rewrite files with --write, run the container with your own uid and gid, so that the files keep your ownership:

docker run --rm --user "$(id -u):$(id -g)" -v $(pwd):/work jfxs/prettier prettier --write .
  • On Linux, --user "$(id -u):$(id -g)" is needed unless your uid is 1000; otherwise prettier fails with EACCES: permission denied.
  • On Docker Desktop (macOS, Windows), file ownership is mapped by Docker: the option is not needed, but it is harmless.
  • With a rootless Docker or Podman, use --user 0:0 (or --userns=keep-id with Podman) to be mapped to your own user.
  • Never use --user root just to write files: they would then belong to root on your host.

⁠Running Prettier in Gitlab-CI

prettier-check:
  image: jfxs/prettier:latest
  stage: lint
  script:
    - prettier --check .

The image has no prettier entrypoint, so the job needs no entrypoint: [""] override. The job runs as uid 1000: use --check in CI (read-only); to commit reformatted files, run --write locally as described above.

⁠Migrating from tmknom/prettier

tmknom/prettier used prettier as entrypoint and /work as working directory. With this image the working directory is the same, but the command must be explicit:

# before
docker run --rm -v $(pwd):/work tmknom/prettier --check .
# after
docker run --rm -v $(pwd):/work jfxs/prettier prettier --check .

Like tmknom/prettier, the container runs as a non-root user: see Writing files⁠ for --write.

⁠Built with

Docker latest tag is 3.9.9-001, 3.9, 3⁠.

The complete software bill of materials (SBOM) of each published image, with its known vulnerabilities, is collected in the sbom-docker⁠ repository, under the component prettier.

Dockerhub Overview page⁠ has the details of the last published image.

⁠Versioning

Docker tag definition:

  • the Prettier version used,
  • a dash
  • an increment to differentiate build with the same version starting at 001
<prettier_version>-<increment>

Example: 3.9.9-001

⁠Signature and attestation

Cosign⁠ public key:

-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEa3yV6+yd/l4zh/tfT6Tx+zn0dhy3
BhFqSad1norLeKSCN2MILv4fZ9GA6ODOlJOw+7vzUvzZVr9IXnxEdjoWJw==
-----END PUBLIC KEY-----

The public key is also available online: https://gitlab.com/op_so/docker/cosign-public-key/-/raw/main/cosign.pub⁠.

To verify an image:

cosign verify --key cosign.pub $IMAGE_URI

To verify and get the software bill of materials (SBOM) attestation:

cosign verify-attestation --key cosign.pub --type spdxjson $IMAGE_URI | jq '.payload | @base64d | fromjson | .predicate'

⁠Authors

⁠License

This program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE⁠ for details.

Tag summary

Content type

Image

Digest

sha256:a3823db65…

Size

135 MB

Last updated

4 days ago

docker pull jfxs/prettier