Skip to content

Commit

Permalink
Explicitly define a nonroot user in the Dockerfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-fritz committed Aug 30, 2023
1 parent 86a17ba commit cf54175
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2020-2022 Christian Fritz <mail@chr-fritz.de>
# Copyright © 2020-2023 Christian Fritz <mail@chr-fritz.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,7 +32,7 @@ builds:
- arm
- arm64
goarm:
- 7
- "7"
ldflags:
- -X 'github.com/chr-fritz/knx-exporter/version.Version={{.Version}}'
- -X 'github.com/chr-fritz/knx-exporter/version.Revision={{.ShortCommit}}'
Expand Down Expand Up @@ -66,6 +66,7 @@ dockers:
- "--platform=linux/amd64"
extra_files:
- pkg/.knx-exporter.yaml
- scripts/docker/etc_passwd
- goos: linux
goarch: arm64
ids:
Expand All @@ -89,6 +90,7 @@ dockers:
- "--platform=linux/arm64/v8"
extra_files:
- pkg/.knx-exporter.yaml
- scripts/docker/etc_passwd
- goos: linux
goarch: arm
goarm: 7
Expand All @@ -113,6 +115,7 @@ dockers:
- "--platform=linux/arm/v7"
extra_files:
- pkg/.knx-exporter.yaml
- scripts/docker/etc_passwd
docker_manifests:
- name_template: "quay.io/chrfritz/knx-exporter:latest"
image_templates:
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2020-2022 Christian Fritz <mail@chr-fritz.de>
# Copyright © 2020-2023 Christian Fritz <mail@chr-fritz.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,10 +13,12 @@
# limitations under the License.

FROM scratch
COPY scripts/docker/etc_passwd /etc/passwd
COPY knx-exporter /
COPY pkg/.knx-exporter.yaml /etc/knx-exporter.yaml
EXPOSE 8080/tcp
EXPOSE 3671/udp
VOLUME /etc/knx-exporter
USER nonroot
ENTRYPOINT ["/knx-exporter"]
CMD ["run", "--config","/etc/knx-exporter.yaml"]
1 change: 1 addition & 0 deletions scripts/docker/etc_passwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nonroot:x:1337:1337:nonroot:/nonroot:/usr/sbin/nologin

0 comments on commit cf54175

Please sign in to comment.