Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
docker-runas-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
docker-runas-test
Commits
a1323d03
Commit
a1323d03
authored
7 years ago
by
nimrod
Browse files
Options
Downloads
Plain Diff
Merge branch 'gosu'
parents
9ab847ec
0cb39d8b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+10
-16
10 additions, 16 deletions
Dockerfile
test.bats
+26
-11
26 additions, 11 deletions
test.bats
with
36 additions
and
27 deletions
Dockerfile
+
10
−
16
View file @
a1323d03
ARG
image
FROM
${image}
RUN if
command
-v
apt-get
;
\
then
\
apt-get update
&&
apt-get
install
-y
sudo
;
\
elif
command
-v
yum
;
\
then
\
yum
install
-y
sudo
;
\
elif
command
-v
apk
;
\
then
\
apk add
--update
--no-cache
sudo
;
\
elif
command
-v
dnf
;
\
then
\
dnf
install
-y
sudo
;
\
fi
ARG
userland
ADD
[ "https://www.shore.co.il/blog/static/runas-${userland}", "/entrypoint" ]
ENTRYPOINT
[ "/bin/sh", "/entrypoint" ]
RUN
apk add
--update
--no-cache
openssl
||
true
&&
\
wget https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64
||
\
curl
-fsSL
https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64
-o
gosu-amd64
&&
\
install
-o
root
-g
root
-m
755 gosu-amd64 /usr/local/bin/gosu
&&
\
rm
gosu-amd64
&&
\
wget https://www.shore.co.il/blog/static/runas
||
\
curl
-fsSL
https://www.shore.co.il/blog/static/runas
-o
runas
&&
\
install
-o
root
-g
root
-m
755 runas /entrypoint
&&
\
rm
runas
ENTRYPOINT
[ "/entrypoint" ]
VOLUME
/data
WORKDIR
/data
ENV
HOME /data
This diff is collapsed.
Click to expand it.
test.bats
+
26
−
11
View file @
a1323d03
#!/usr/bin/env bats
_test () {
_test
_root
() {
name="${1:-$BATS_TEST_DESCRIPTION}"
tag="${2:-latest}"
userland="${3:-gnu}"
docker build -t "runas-$name" --build-arg "image=$name:$tag" --build-arg "userland=$userland" ./
docker run --rm -v "$BATS_TEST_DIRNAME:/data" "runas-$name" touch "$name.touch"
test "$(id -u)" = "$(stat -c '%u' $name.touch)"
test "$(id -g)" = "$(stat -c '%g' $name.touch)"
docker build -t "runas-$name" --build-arg "image=$name:$tag" ./
docker run --rm -v "$BATS_TEST_DIRNAME:/data" "runas-$name" touch "$name.root"
test "$(id -u)" = "$(stat -c '%u' $name.root)"
test "$(id -g)" = "$(stat -c '%g' $name.root)"
}
_test_user () {
name="${1:-$BATS_TEST_DESCRIPTION}"
tag="${2:-latest}"
user="$(id -u)"
group="$(id -g)"
docker build -t "runas-$name" --build-arg "image=$name:$tag" ./
docker run -u "$user:$group" --rm -v "$BATS_TEST_DIRNAME:/data" "runas-$name" touch "$name.user"
test "$user" = "$(stat -c '%u' $name.user)"
test "$user" = "$(stat -c '%g' $name.user)"
}
teardown () {
...
...
@@ -15,8 +25,13 @@ teardown () {
rm -f *.touch
}
@test "ubuntu" { _test; }
@test "debian" { _test debian stable-slim; }
@test "centos" { _test; }
@test "fedora" { _test; }
@test "alpine" { _test alpine latest busybox; }
@test "ubuntu" { _test_root buildpack-deps bionic; }
@test "debian" { _test_root buildpack-deps stretch; }
@test "centos" { _test_root; }
@test "fedora" { _test_root; }
@test "alpine" { _test_root; }
@test "ubuntu" { _test_user buildpack-deps bionic; }
@test "debian" { _test_user buildpack-deps stretch; }
@test "centos" { _test_user; }
@test "fedora" { _test_user; }
@test "alpine" { _test_user; }
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment