From fd64fd1ad164c74f1f207c27e449ac6347604de7 Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Fri, 16 Feb 2018 02:24:38 +0100 Subject: [PATCH 01/13] mono-choco defaults to help --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index cea2e52..241dbe2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,3 +20,4 @@ COPY --from=builder "/usr/local/src/choco/choco-$chocoVersion/build_output/choco COPY bin/choco /usr/bin/choco ENTRYPOINT ["/usr/bin/choco"] +CMD ["-h"] From a5fbcda210621b9d2c10c608f62b207ec4226087 Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Fri, 16 Feb 2018 02:35:42 +0100 Subject: [PATCH 02/13] switch to alpine-mono --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 241dbe2..3070269 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,10 +12,9 @@ RUN chmod +x build.sh zip.sh RUN ./build.sh -v -FROM alpine +FROM frolvlad/alpine-mono ARG chocoVersion=stable -RUN apk add --no-cache mono --repository http://nl.alpinelinux.org/alpine/edge/testing COPY --from=builder "/usr/local/src/choco/choco-$chocoVersion/build_output/chocolatey" /opt/chocolatey COPY bin/choco /usr/bin/choco From d92ce7b67912c0873d8acaa0eaa9de01f612ef4e Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Fri, 16 Feb 2018 04:06:27 +0100 Subject: [PATCH 03/13] second build state is version-agnostic --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3070269..00df535 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,19 +3,19 @@ ARG chocoVersion=stable RUN apt-get update && apt-get install -y wget tar gzip -WORKDIR /usr/local/src/choco -RUN wget "https://github.com/chocolatey/choco/archive/$chocoVersion.tar.gz" -RUN tar -xzf "$chocoVersion.tar.gz" +WORKDIR /usr/local/src +RUN wget https://github.com/chocolatey/choco/archive/$chocoVersion.tar.gz +RUN tar -xzf $chocoVersion.tar.gz +RUN mv choco-$chocoVersion choco -WORKDIR /usr/local/src/choco/choco-$chocoVersion +WORKDIR /usr/local/src/choco RUN chmod +x build.sh zip.sh RUN ./build.sh -v FROM frolvlad/alpine-mono -ARG chocoVersion=stable -COPY --from=builder "/usr/local/src/choco/choco-$chocoVersion/build_output/chocolatey" /opt/chocolatey +COPY --from=builder /usr/local/src/choco/build_output/chocolatey /opt/chocolatey COPY bin/choco /usr/bin/choco ENTRYPOINT ["/usr/bin/choco"] From 0b17ecc4b8699a9061b80f5a2b7a02e7901e5f40 Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Fri, 16 Feb 2018 19:20:11 +0100 Subject: [PATCH 04/13] change of container user possible --- Dockerfile | 3 ++- bin/choco | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 00df535..5f566eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,8 @@ RUN ./build.sh -v FROM frolvlad/alpine-mono -COPY --from=builder /usr/local/src/choco/build_output/chocolatey /opt/chocolatey +RUN apk add --no-cache shadow +COPY --from=builder /usr/local/src/choco/build_output/chocolatey /opt/chocolatey/ COPY bin/choco /usr/bin/choco ENTRYPOINT ["/usr/bin/choco"] diff --git a/bin/choco b/bin/choco index b9e87ac..e14e45e 100755 --- a/bin/choco +++ b/bin/choco @@ -4,11 +4,34 @@ set -e # choco dumps a ton of stuff in the PWD/opt # This hack will clean it up automatically. function cleanup { - if [ -d opt ]; then + if [ "$PWD" != "/" ] && [ -d opt ]; then rm -rf opt fi } trap cleanup EXIT +USER=root +if [ -n "$UID" ] && [ "$UID" -gt "0" ]; then + USER=chocolatey + + if [ -n "$GID" ] && [ "$GID" -gt "0" ]; then + groupadd -f -g $GID chocolatey + + if [ "$UID" -lt "1000" ]; then + useradd -r -N -g $GID -e '' -s /bin/sh -u $UID $USER + else + useradd -M -N -g $GID -e '' -s /bin/sh -u $UID $USER + fi + else + if [ "$UID" -lt "1000" ]; then + useradd -r -U -e '' -s /bin/sh -u $UID $USER + else + useradd -M -U -e '' -s /bin/sh -u $UID $USER + fi + fi +fi + + # Wrap the mono choco.exe command -mono /opt/chocolatey/choco.exe "$@" --allow-unofficial \ No newline at end of file +command="mono /opt/chocolatey/choco.exe $@ --allow-unofficial" +su -c "$command" $USER From c04f93294e66c808e77e12229c153b0d1f0083f9 Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Fri, 16 Feb 2018 19:34:31 +0100 Subject: [PATCH 05/13] Updating READMEs --- README.md | 2 +- example/README.md | 6 +++--- example/mypackage/mypackage.nuspec | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a685a66..e46ea2c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ Docker image for creating a container with Chocolatey running on Mono ## Usage -Test the image using `docker run -ti --rm -v $PWD:/root -w /root linuturk/mono-choco -h` +Test the image using `docker run --rm -v $PWD:/root -w /root linuturk/mono-choco` See [the example directory](./example/README.md) for a basic package example. diff --git a/example/README.md b/example/README.md index a772b01..f08016b 100644 --- a/example/README.md +++ b/example/README.md @@ -4,10 +4,10 @@ This directory contains an example package and Dockerfile. ## Generating a new package -The **mypackage** directory was generated using the following command. Note you will need to fix the ownership of these files as they are generated as the root user inside the container. +The **mypackage** directory was generated using the following command. Note you will need to fix the ownership of these files if you omit `-e UID=$UID` as they are generated as the root user inside the container. ```bash -docker run -ti --rm -v $PWD:/root -w /root linuturk/mono-choco new mypackage --version 1.0.0 --maintainer "Justin Phelps" +docker run -ti --rm -e UID=$UID -v $PWD:/root -w /root linuturk/mono-choco new mypackage --version 1.0.0 --maintainer "Justin Phelps" ``` There are some modifications necessary to the generated nuspec file before it will generate a package. Check the file's git history to see those changes. @@ -18,7 +18,7 @@ I recommend you use the Dockerfile example in this directory to pack your nuget ```bash cd /path/to/mypackage -docker run --rm --volume $PWD:$PWD -w $PWD linuturk/mono-choco pack mypackage.nuspec +docker run --rm -v $PWD:$PWD -w $PWD linuturk/mono-choco pack mypackage.nuspec Chocolatey v0.10.9.0 Directory 'opt/chocolatey/lib' does not exist. diff --git a/example/mypackage/mypackage.nuspec b/example/mypackage/mypackage.nuspec index 7728fd7..5100301 100644 --- a/example/mypackage/mypackage.nuspec +++ b/example/mypackage/mypackage.nuspec @@ -75,6 +75,6 @@ This is a nuspec. It mostly adheres to https://docs.nuget.org/create/Nuspec-Refe - + From c2892bd75f521c360d8766a072d395c967c23f6b Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Fri, 16 Feb 2018 20:01:12 +0100 Subject: [PATCH 06/13] make useradd discreet --- bin/choco | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/choco b/bin/choco index e14e45e..02aaab1 100755 --- a/bin/choco +++ b/bin/choco @@ -18,15 +18,15 @@ if [ -n "$UID" ] && [ "$UID" -gt "0" ]; then groupadd -f -g $GID chocolatey if [ "$UID" -lt "1000" ]; then - useradd -r -N -g $GID -e '' -s /bin/sh -u $UID $USER + useradd -r -N -g $GID -e '' -s /bin/sh -u $UID $USER > /dev/null 2>&1 else - useradd -M -N -g $GID -e '' -s /bin/sh -u $UID $USER + useradd -M -N -g $GID -e '' -s /bin/sh -u $UID $USER > /dev/null 2>&1 fi else if [ "$UID" -lt "1000" ]; then - useradd -r -U -e '' -s /bin/sh -u $UID $USER + useradd -r -U -e '' -s /bin/sh -u $UID $USER > /dev/null 2>&1 else - useradd -M -U -e '' -s /bin/sh -u $UID $USER + useradd -M -U -e '' -s /bin/sh -u $UID $USER > /dev/null 2>&1 fi fi fi From 9b3367a91fd34f30ea45ecf6c2e6c1499bfb99b8 Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Sun, 18 Feb 2018 17:18:33 +0100 Subject: [PATCH 07/13] honoring SYS_XID_MIN ( > 100 ) --- bin/choco | 33 ++++++++++++++++----------------- example/README.md | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/bin/choco b/bin/choco index 02aaab1..c448cf1 100755 --- a/bin/choco +++ b/bin/choco @@ -5,30 +5,29 @@ set -e # This hack will clean it up automatically. function cleanup { if [ "$PWD" != "/" ] && [ -d opt ]; then - rm -rf opt + rm -rf opt fi } trap cleanup EXIT + USER=root -if [ -n "$UID" ] && [ "$UID" -gt "0" ]; then - USER=chocolatey +if [ -n "$UID" ] && [ "$UID" -gt "100" ]; then + USER=chocolatey + GROUP=chocolatey - if [ -n "$GID" ] && [ "$GID" -gt "0" ]; then - groupadd -f -g $GID chocolatey + if [ -n "$GID" ] && [ "$GID" -gt "100" ]; then + groupadd -g $GID $GROUP + else + GID=$UID + groupadd -g $GID $GROUP + fi - if [ "$UID" -lt "1000" ]; then - useradd -r -N -g $GID -e '' -s /bin/sh -u $UID $USER > /dev/null 2>&1 - else - useradd -M -N -g $GID -e '' -s /bin/sh -u $UID $USER > /dev/null 2>&1 - fi - else - if [ "$UID" -lt "1000" ]; then - useradd -r -U -e '' -s /bin/sh -u $UID $USER > /dev/null 2>&1 - else - useradd -M -U -e '' -s /bin/sh -u $UID $USER > /dev/null 2>&1 - fi - fi + if [ "$UID" -lt "1000" ]; then + useradd -r -N -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 + else + useradd -M -N -e '' -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 + fi fi diff --git a/example/README.md b/example/README.md index f08016b..a6f3aa1 100644 --- a/example/README.md +++ b/example/README.md @@ -4,7 +4,7 @@ This directory contains an example package and Dockerfile. ## Generating a new package -The **mypackage** directory was generated using the following command. Note you will need to fix the ownership of these files if you omit `-e UID=$UID` as they are generated as the root user inside the container. +The **mypackage** directory was generated using the following command. Note, if you omit `-e UID=$UID` you will need to fix the ownership of these files as they are generated as the root user inside the container. ```bash docker run -ti --rm -e UID=$UID -v $PWD:/root -w /root linuturk/mono-choco new mypackage --version 1.0.0 --maintainer "Justin Phelps" From 0072a9f24fd40446d124dae4f63c9953aff498bf Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Sun, 18 Feb 2018 17:27:29 +0100 Subject: [PATCH 08/13] cleanup in choco --- bin/choco | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/choco b/bin/choco index c448cf1..55e05b5 100755 --- a/bin/choco +++ b/bin/choco @@ -13,7 +13,7 @@ trap cleanup EXIT USER=root if [ -n "$UID" ] && [ "$UID" -gt "100" ]; then - USER=chocolatey + USER=chocolatey GROUP=chocolatey if [ -n "$GID" ] && [ "$GID" -gt "100" ]; then From 34dbbfbfca58abeefcf5cdce47c3f4df0da032c2 Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Sun, 18 Feb 2018 17:31:10 +0100 Subject: [PATCH 09/13] another cleanup in choco :( --- bin/choco | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/choco b/bin/choco index 55e05b5..ebd2491 100755 --- a/bin/choco +++ b/bin/choco @@ -16,12 +16,12 @@ if [ -n "$UID" ] && [ "$UID" -gt "100" ]; then USER=chocolatey GROUP=chocolatey - if [ -n "$GID" ] && [ "$GID" -gt "100" ]; then + if [ -n "$GID" ] && [ "$GID" -gt "100" ]; then groupadd -g $GID $GROUP - else + else GID=$UID groupadd -g $GID $GROUP - fi + fi if [ "$UID" -lt "1000" ]; then useradd -r -N -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 From 61b9cef74bc3f8ecc4394cf634b01641d2b1ba76 Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Mon, 19 Feb 2018 16:39:36 +0100 Subject: [PATCH 10/13] Pulling chances from Linuturk@377b74dcb462b86f078d390ef94107a7a8afaf47 --- Dockerfile | 14 +++++++------- README.md | 2 +- bin/choco | 14 ++++++-------- example/README.md | 6 +++--- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f566eb..27a07b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,22 @@ FROM mono:3.12.1 as builder -ARG chocoVersion=stable +ARG CHOCOVERSION=stable RUN apt-get update && apt-get install -y wget tar gzip WORKDIR /usr/local/src -RUN wget https://github.com/chocolatey/choco/archive/$chocoVersion.tar.gz -RUN tar -xzf $chocoVersion.tar.gz -RUN mv choco-$chocoVersion choco +RUN wget "https://github.com/chocolatey/choco/archive/${CHOCOVERSION}.tar.gz" +RUN tar -xzf "${CHOCOVERSION}.tar.gz" +RUN mv "choco-${CHOCOVERSION}" choco WORKDIR /usr/local/src/choco RUN chmod +x build.sh zip.sh RUN ./build.sh -v -FROM frolvlad/alpine-mono +FROM alpine:latest -RUN apk add --no-cache shadow -COPY --from=builder /usr/local/src/choco/build_output/chocolatey /opt/chocolatey/ +RUN apk add --no-cache mono shadow --repository http://nl.alpinelinux.org/alpine/edge/testing +COPY --from=builder /usr/local/src/choco/build_output/chocolatey /opt/chocolatey COPY bin/choco /usr/bin/choco ENTRYPOINT ["/usr/bin/choco"] diff --git a/README.md b/README.md index e46ea2c..cecc880 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ Docker image for creating a container with Chocolatey running on Mono ## Usage -Test the image using `docker run --rm -v $PWD:/root -w /root linuturk/mono-choco` +Test the image using `docker run --rm -v $PWD:$PWD -w $PWD linuturk/mono-choco` See [the example directory](./example/README.md) for a basic package example. diff --git a/bin/choco b/bin/choco index ebd2491..daaad1e 100755 --- a/bin/choco +++ b/bin/choco @@ -4,8 +4,8 @@ set -e # choco dumps a ton of stuff in the PWD/opt # This hack will clean it up automatically. function cleanup { - if [ "$PWD" != "/" ] && [ -d opt ]; then - rm -rf opt + if [ $PWD != "/" ] && [ -d opt ]; then + rm -rf opt fi } trap cleanup EXIT @@ -16,12 +16,10 @@ if [ -n "$UID" ] && [ "$UID" -gt "100" ]; then USER=chocolatey GROUP=chocolatey - if [ -n "$GID" ] && [ "$GID" -gt "100" ]; then - groupadd -g $GID $GROUP - else - GID=$UID - groupadd -g $GID $GROUP + if [ -z "$GID" ] || [ "$GID" -lt "101" ]; then + GID=$UID fi + groupadd -g $GID $GROUP if [ "$UID" -lt "1000" ]; then useradd -r -N -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 @@ -32,5 +30,5 @@ fi # Wrap the mono choco.exe command -command="mono /opt/chocolatey/choco.exe $@ --allow-unofficial" +command="mono /opt/chocolatey/choco.exe $@ --allow-unofficial" su -c "$command" $USER diff --git a/example/README.md b/example/README.md index a6f3aa1..e8d859f 100644 --- a/example/README.md +++ b/example/README.md @@ -7,7 +7,7 @@ This directory contains an example package and Dockerfile. The **mypackage** directory was generated using the following command. Note, if you omit `-e UID=$UID` you will need to fix the ownership of these files as they are generated as the root user inside the container. ```bash -docker run -ti --rm -e UID=$UID -v $PWD:/root -w /root linuturk/mono-choco new mypackage --version 1.0.0 --maintainer "Justin Phelps" +docker run --rm -e UID=$UID -v $PWD:$PWD -w $PWD linuturk/mono-choco new mypackage --version 1.0.0 --maintainer "Justin Phelps" ``` There are some modifications necessary to the generated nuspec file before it will generate a package. Check the file's git history to see those changes. @@ -18,12 +18,12 @@ I recommend you use the Dockerfile example in this directory to pack your nuget ```bash cd /path/to/mypackage -docker run --rm -v $PWD:$PWD -w $PWD linuturk/mono-choco pack mypackage.nuspec +docker run --rm -e UID=$UID -v $PWD:$PWD -w $PWD linuturk/mono-choco pack mypackage.nuspec Chocolatey v0.10.9.0 Directory 'opt/chocolatey/lib' does not exist. Chocolatey is not an official build (bypassed with --allow-unofficial). - If you are seeing this message and it is not expected, your system may + If you are seeing this message and it is not expected, your system may now be in a bad state. Only official builds are to be trusted. Attempting to build package from 'mypackage.nuspec'. From 4cb54f664c96e09ea4e041af333d4147bdc0fa12 Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Mon, 19 Feb 2018 17:22:00 +0100 Subject: [PATCH 11/13] droping user changing work in favour of docker-based workflow (see Linuturk/mono-choco#9) --- Dockerfile | 2 +- bin/choco | 22 +--------------------- example/README.md | 6 +++--- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 27a07b1..ce386e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN ./build.sh -v FROM alpine:latest -RUN apk add --no-cache mono shadow --repository http://nl.alpinelinux.org/alpine/edge/testing +RUN apk add --no-cache mono --repository http://nl.alpinelinux.org/alpine/edge/testing COPY --from=builder /usr/local/src/choco/build_output/chocolatey /opt/chocolatey COPY bin/choco /usr/bin/choco diff --git a/bin/choco b/bin/choco index daaad1e..3e4de76 100755 --- a/bin/choco +++ b/bin/choco @@ -10,25 +10,5 @@ function cleanup { } trap cleanup EXIT - -USER=root -if [ -n "$UID" ] && [ "$UID" -gt "100" ]; then - USER=chocolatey - GROUP=chocolatey - - if [ -z "$GID" ] || [ "$GID" -lt "101" ]; then - GID=$UID - fi - groupadd -g $GID $GROUP - - if [ "$UID" -lt "1000" ]; then - useradd -r -N -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 - else - useradd -M -N -e '' -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 - fi -fi - - # Wrap the mono choco.exe command -command="mono /opt/chocolatey/choco.exe $@ --allow-unofficial" -su -c "$command" $USER +mono /opt/chocolatey/choco.exe "$@" --allow-unofficial diff --git a/example/README.md b/example/README.md index e8d859f..ab32543 100644 --- a/example/README.md +++ b/example/README.md @@ -4,10 +4,10 @@ This directory contains an example package and Dockerfile. ## Generating a new package -The **mypackage** directory was generated using the following command. Note, if you omit `-e UID=$UID` you will need to fix the ownership of these files as they are generated as the root user inside the container. +The **mypackage** directory was generated using the following command. Note you will need to fix the ownership of these files as they are generated as the root user inside the container. ```bash -docker run --rm -e UID=$UID -v $PWD:$PWD -w $PWD linuturk/mono-choco new mypackage --version 1.0.0 --maintainer "Justin Phelps" +docker run --rm -v $PWD:$PWD -w $PWD linuturk/mono-choco new mypackage --version 1.0.0 --maintainer "Justin Phelps" ``` There are some modifications necessary to the generated nuspec file before it will generate a package. Check the file's git history to see those changes. @@ -18,7 +18,7 @@ I recommend you use the Dockerfile example in this directory to pack your nuget ```bash cd /path/to/mypackage -docker run --rm -e UID=$UID -v $PWD:$PWD -w $PWD linuturk/mono-choco pack mypackage.nuspec +docker run --rm -v $PWD:$PWD -w $PWD linuturk/mono-choco pack mypackage.nuspec Chocolatey v0.10.9.0 Directory 'opt/chocolatey/lib' does not exist. From 77501df5b370f8454cb706e500db83d61730fdce Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Tue, 20 Feb 2018 13:33:05 +0100 Subject: [PATCH 12/13] outsourcing user changing work into entrypoint.sh --- Dockerfile | 9 +++++++-- bin/choco | 22 +--------------------- bin/entrypoint.sh | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 23 deletions(-) create mode 100755 bin/entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 27a07b1..170a8d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,9 +15,14 @@ RUN ./build.sh -v FROM alpine:latest -RUN apk add --no-cache mono shadow --repository http://nl.alpinelinux.org/alpine/edge/testing +RUN apk add --no-cache mono --repository http://nl.alpinelinux.org/alpine/edge/testing && \ + apk add --no-cache shadow ca-certificates && \ + cert-sync /etc/ssl/certs/ca-certificates.crt && \ + apk del ca-certificates + COPY --from=builder /usr/local/src/choco/build_output/chocolatey /opt/chocolatey COPY bin/choco /usr/bin/choco +COPY bin/entrypoint.sh /root/entrypoint.sh -ENTRYPOINT ["/usr/bin/choco"] +ENTRYPOINT ["/root/entrypoint.sh"] CMD ["-h"] diff --git a/bin/choco b/bin/choco index daaad1e..3e4de76 100755 --- a/bin/choco +++ b/bin/choco @@ -10,25 +10,5 @@ function cleanup { } trap cleanup EXIT - -USER=root -if [ -n "$UID" ] && [ "$UID" -gt "100" ]; then - USER=chocolatey - GROUP=chocolatey - - if [ -z "$GID" ] || [ "$GID" -lt "101" ]; then - GID=$UID - fi - groupadd -g $GID $GROUP - - if [ "$UID" -lt "1000" ]; then - useradd -r -N -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 - else - useradd -M -N -e '' -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 - fi -fi - - # Wrap the mono choco.exe command -command="mono /opt/chocolatey/choco.exe $@ --allow-unofficial" -su -c "$command" $USER +mono /opt/chocolatey/choco.exe "$@" --allow-unofficial diff --git a/bin/entrypoint.sh b/bin/entrypoint.sh new file mode 100755 index 0000000..71af3df --- /dev/null +++ b/bin/entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +USER=root +if [ -n "$UID" ] && [ "$UID" -gt "100" ]; then + USER=chocolatey + GROUP=chocolatey + + if [ -z "$GID" ] || [ "$GID" -lt "101" ]; then + GID=$UID + fi + groupadd -g $GID $GROUP + + if [ "$UID" -lt "1000" ]; then + useradd -r -N -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 + else + useradd -M -N -e '' -g $GID -s /bin/sh -u $UID $USER > /dev/null 2>&1 + fi +fi + +command="/usr/bin/choco $@" +su -c "$command" $USER From 13543b0319255a385e68c6012fd848e513476b8a Mon Sep 17 00:00:00 2001 From: kobilous <35497148+kobilous@users.noreply.github.com> Date: Fri, 23 Feb 2018 16:00:19 +0100 Subject: [PATCH 13/13] pulling changes from Linuturk@eb29d35b44dd877f47781ab9800e135ac9d4e1a6 --- Dockerfile | 8 ++------ bin/choco | 2 +- bin/entrypoint.sh | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 170a8d3..3206c1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,12 +13,8 @@ RUN chmod +x build.sh zip.sh RUN ./build.sh -v -FROM alpine:latest - -RUN apk add --no-cache mono --repository http://nl.alpinelinux.org/alpine/edge/testing && \ - apk add --no-cache shadow ca-certificates && \ - cert-sync /etc/ssl/certs/ca-certificates.crt && \ - apk del ca-certificates +FROM debian +RUN apt update && apt install -y login mono-devel passwd && apt-get clean all COPY --from=builder /usr/local/src/choco/build_output/chocolatey /opt/chocolatey COPY bin/choco /usr/bin/choco diff --git a/bin/choco b/bin/choco index 3e4de76..df167ee 100755 --- a/bin/choco +++ b/bin/choco @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e # choco dumps a ton of stuff in the PWD/opt diff --git a/bin/entrypoint.sh b/bin/entrypoint.sh index 71af3df..5eeeb1b 100755 --- a/bin/entrypoint.sh +++ b/bin/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e USER=root @@ -7,7 +7,7 @@ if [ -n "$UID" ] && [ "$UID" -gt "100" ]; then GROUP=chocolatey if [ -z "$GID" ] || [ "$GID" -lt "101" ]; then - GID=$UID + GID=$UID fi groupadd -g $GID $GROUP