-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
run container as non root user #33
base: main
Are you sure you want to change the base?
Conversation
🔍 Vulnerabilities of
|
digest | sha256:85e2df67102ea16387af45df974bbf68148ff723f32f36dd633bcf9f8b88138a |
vulnerabilities | |
size | 158 MB |
packages | 324 |
📦 Base Image ruby:2-alpine
also known as |
|
digest | sha256:45ca5ff1e098ddc85430bad09d433dfab4be9417477a5778568a7877408f1cd0 |
vulnerabilities |
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description |
hmm, damn, in my local tests this worked :( |
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
95fb55e
to
a9dcd36
Compare
.github/workflows/ci.yaml
Outdated
docker run --user 1001 --rm -v $(pwd):/repo ci/voxbox-${{ matrix.rubygem_puppet }}:${{ github.sha }} -f /Rakefile syntax | ||
docker run --user 1001 --rm -v $(pwd):/repo ci/voxbox-${{ matrix.rubygem_puppet }}:${{ github.sha }} -f /Rakefile spec | ||
docker run --user 1001 --rm -v $(pwd):/repo ci/voxbox-${{ matrix.rubygem_puppet }}:${{ github.sha }} -f /Rakefile r10k:syntax | ||
docker run --user 1001 --rm -v $(pwd):/repo ci/voxbox-${{ matrix.rubygem_puppet }}:${{ github.sha }} -f /Rakefile r10k:dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when we use the container locally, do we now have to set --user
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, you just can used it as always. at least on my mac it was working like this.
can you maybe test this on a non mac?
docker build -t voxbox-local .
cd path/to/puppet-example
docker run -it --rm -v $(pwd):/repo voxbox-local -f /Rakefile strings:validate:reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could be, that one does need code like this in a compose file. but thats how this id done, afaik
environment:
- PUID=1001
- PGID=1001
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build output: https://gist.github.com/bastelfreak/4cc2e9febafd4f40cf4a0769ad3c9672
and the rake task fails:
$ docker run -it --rm -v $(pwd):/repo voxbox-local -f /Rakefile strings:validate:reference
/usr/local/bundle/gems/io-event-1.6.5/lib/io/event/support.rb:27: warning: IO::Buffer is experimental and both the Ruby and C interface may change in the future!
WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
racc (>= 0)
Available/installed versions of this gem:
- 1.8.1
- 1.6.2
minitest (>= 5.1, ~> 5.4)
Available/installed versions of this gem:
- 5.24.1
- 5.16.3
drb (>= 0)
Available/installed versions of this gem:
- 2.2.1
- 2.1.1
mutex_m (>= 0)
Available/installed versions of this gem:
- 0.2.0
- 0.1.2
WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
Please report a bug if this causes problems.
rake aborted!
Errno::EACCES: Permission denied @ dir_s_mkdir - .yardoc (Errno::EACCES)
/usr/local/bundle/gems/yard-0.9.36/lib/yard/core_ext/file.rb:59:in `open!'
/usr/local/bundle/gems/yard-0.9.36/lib/yard/serializers/yardoc_serializer.rb:55:in `lock_for_writing'
/usr/local/bundle/gems/yard-0.9.36/lib/yard/registry_store.rb:202:in `lock_for_writing'
/usr/local/bundle/gems/yard-0.9.36/lib/yard/registry.rb:210:in `lock_for_writing'
/usr/local/bundle/gems/yard-0.9.36/lib/yard/cli/yardoc.rb:258:in `run'
/usr/local/bundle/gems/yard-0.9.36/lib/yard/cli/command.rb:14:in `run'
/usr/local/bundle/gems/puppet-strings-4.1.2/lib/puppet-strings.rb:48:in `generate'
/usr/local/bundle/gems/puppet-strings-4.1.2/lib/puppet-strings/tasks/validate.rb:29:in `block (4 levels) in <top (required)>'
/usr/local/bundle/gems/puppet-strings-4.1.2/lib/puppet-strings/tasks/validate.rb:21:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => strings:validate:reference
(See full trace by running task with --trace)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i cannot find how to prevent yard from creating this dir. also i read on the net, that it is common to run the container with --user
? any opinions on this?
.github/workflows/ci.yaml
Outdated
@@ -53,6 +57,12 @@ jobs: | |||
RUBYGEM_OVERCOMMIT=${{ matrix.rubygem_overcommit }} | |||
RUBYGEM_MODULESYNC=${{ matrix.rubygem_modulesync }} | |||
|
|||
- name: Upload voxbox-${{ matrix.rubygem_puppet }}_${{ github.sha }}.tar | |||
uses: actions/upload-artifact@v4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does the step exist? so the other job can acccess the build artifact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TLDR: yes
if you build a container in on job, you cannot use it in another, because the local registry gets cleaned. So im uploading it as an artifact and donwload it in the next again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's an artifact size limit we have per repo. I don't know if artifacts expire after X days or if we need to purge them. We should check that in some weeks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was thinking about this too, but then forgot 👍
- also update gha setup to reflect this change - differentiate between build and test of the container Signed-off-by: Robert Waffen <[email protected]>
Signed-off-by: Robert Waffen <[email protected]>
a9dcd36
to
1b8227d
Compare
Dockerfile
Outdated
@@ -73,5 +73,8 @@ RUN apk update \ | |||
|
|||
WORKDIR /repo | |||
|
|||
RUN addgroup -S voxbox && adduser -S voxbox -G voxbox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do those parameters do? Is there maybe a long version that we could use? I think that makes the whole Dockerfile easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nein! there are no long parameters in alpine. it may cost to much space! -S is for system
/ # addgroup --help
BusyBox v1.36.1 (2024-06-10 07:11:47 UTC) multi-call binary.
Usage: addgroup [-g GID] [-S] [USER] GROUP
Add a group or add a user to a group
-g GID Group id
-S Create a system group
/ # adduser --help
BusyBox v1.36.1 (2024-06-10 07:11:47 UTC) multi-call binary.
Usage: adduser [OPTIONS] USER [GROUP]
Create new user, or add USER to GROUP
-h DIR Home directory
-g GECOS GECOS field
-s SHELL Login shell
-G GRP Group
-S Create a system user
-D Don't assign a password
-H Don't create home directory
-u UID User id
-k SKEL Skeleton directory (/etc/skel)
/ #
Signed-off-by: Robert Waffen <[email protected]>
No description provided.