Skip to content

Commit

Permalink
merge user-changing-work into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kobilous committed Feb 20, 2018
2 parents 4cb54f6 + 77501df commit 40c9796
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ RUN ./build.sh -v

FROM alpine:latest

RUN apk add --no-cache mono --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"]
22 changes: 22 additions & 0 deletions bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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 --rm -v $PWD:$PWD -w $PWD 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.
Expand All @@ -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 -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.

Expand Down

0 comments on commit 40c9796

Please sign in to comment.