Skip to content

Commit

Permalink
feat(permissions): create user owned directory for DB in container (#41)
Browse files Browse the repository at this point in the history
Creates a new directory /data inside the docker container to store the grype DB, this directory is chowned to the docker user 1000 to make sure that the container can run without a volume mount.
  • Loading branch information
adamtagscherer authored Aug 23, 2023
1 parent 9abbd7a commit 3ce91b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ WORKDIR /app

COPY --from=builder ["/build/grype-server/grype-server", "./grype-server"]

ENV DB_ROOT_DIR=/data

RUN mkdir -p $DB_ROOT_DIR \
&& chown 1000:1000 $DB_ROOT_DIR

USER 1000:1000

ENTRYPOINT ["/app/grype-server"]

USER 1000
CMD ["run"]

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
Expand Down
2 changes: 1 addition & 1 deletion grype-server/cmd/grype-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func run(c *cli.Context) {
func main() {
viper.SetDefault(config.RestServerPort, "9991")
viper.SetDefault(config.HealthCheckAddress, ":8080")
viper.SetDefault(config.DbRootDir, "/app/")
viper.SetDefault(config.DbRootDir, "./")
viper.SetDefault(config.DbUpdateURL, "https://toolbox-data.anchore.io/grype/databases/listing.json")
viper.AutomaticEnv()

Expand Down

0 comments on commit 3ce91b1

Please sign in to comment.