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
ARG
image
FROM
${image}
FROM
${image}
RUN if
command
-v
apt-get
;
\
RUN
apk add
--update
--no-cache
openssl
||
true
&&
\
then
\
wget https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64
||
\
apt-get update
&&
apt-get
install
-y
sudo
;
\
curl
-fsSL
https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64
-o
gosu-amd64
&&
\
elif
command
-v
yum
;
\
install
-o
root
-g
root
-m
755 gosu-amd64 /usr/local/bin/gosu
&&
\
then
\
rm
gosu-amd64
&&
\
yum
install
-y
sudo
;
\
wget https://www.shore.co.il/blog/static/runas
||
\
elif
command
-v
apk
;
\
curl
-fsSL
https://www.shore.co.il/blog/static/runas
-o
runas
&&
\
then
\
install
-o
root
-g
root
-m
755 runas /entrypoint
&&
\
apk add
--update
--no-cache
sudo
;
\
rm
runas
elif
command
-v
dnf
;
\
ENTRYPOINT
[ "/entrypoint" ]
then
\
dnf
install
-y
sudo
;
\
fi
ARG
userland
ADD
[ "https://www.shore.co.il/blog/static/runas-${userland}", "/entrypoint" ]
ENTRYPOINT
[ "/bin/sh", "/entrypoint" ]
VOLUME
/data
VOLUME
/data
WORKDIR
/data
WORKDIR
/data
ENV
HOME /data
ENV
HOME /data
This diff is collapsed.
Click to expand it.
test.bats
+
26
−
11
View file @
a1323d03
#!/usr/bin/env bats
#!/usr/bin/env bats
_test () {
_test
_root
() {
name="${1:-$BATS_TEST_DESCRIPTION}"
name="${1:-$BATS_TEST_DESCRIPTION}"
tag="${2:-latest}"
tag="${2:-latest}"
userland="${3:-gnu}"
docker build -t "runas-$name" --build-arg "image=$name:$tag" ./
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.root"
docker run --rm -v "$BATS_TEST_DIRNAME:/data" "runas-$name" touch "$name.touch"
test "$(id -u)" = "$(stat -c '%u' $name.root)"
test "$(id -u)" = "$(stat -c '%u' $name.touch)"
test "$(id -g)" = "$(stat -c '%g' $name.root)"
test "$(id -g)" = "$(stat -c '%g' $name.touch)"
}
_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 () {
teardown () {
...
@@ -15,8 +25,13 @@ teardown () {
...
@@ -15,8 +25,13 @@ teardown () {
rm -f *.touch
rm -f *.touch
}
}
@test "ubuntu" { _test; }
@test "ubuntu" { _test_root buildpack-deps bionic; }
@test "debian" { _test debian stable-slim; }
@test "debian" { _test_root buildpack-deps stretch; }
@test "centos" { _test; }
@test "centos" { _test_root; }
@test "fedora" { _test; }
@test "fedora" { _test_root; }
@test "alpine" { _test alpine latest busybox; }
@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