diff --git a/docker/Dockerfile.linux b/docker/Dockerfile.linux index f5d825a099..08b6fa0342 100644 --- a/docker/Dockerfile.linux +++ b/docker/Dockerfile.linux @@ -1,21 +1,43 @@ -FROM mono:6.12 - -MAINTAINER Justin Phelps +ARG monoversion="6.12" +FROM mono:${monoversion} as build RUN apt-get update && apt-get install git -y COPY . /usr/local/src/choco/ WORKDIR /usr/local/src/choco -RUN chmod +x build.sh -RUN chmod +x zip.sh -RUN ./build.sh +RUN chmod +x *.sh + +ARG buildscript="build.sh" +RUN ./$buildscript + +RUN if [ "$buildscript" = "build.official.sh" ]; then \ + cp docker/choco_official_wrapper code_drop/chocolatey/console/choco_wrapper; \ + else \ + cp docker/choco_wrapper code_drop/chocolatey/console/choco_wrapper; \ + fi; + + +ARG monoversion="6.12" +FROM mono:${monoversion} as install + +ARG monoversion="6.12" +LABEL org.opencontainers.image.url="https://chocolatey.org/" +LABEL org.opencontainers.image.documentation="https://docs.chocolatey.org/" +LABEL org.opencontainers.image.source="https://github.com/chocolatey/choco" +LABEL org.opencontainers.image.vendor="Chocolatey Software, Inc" +LABEL org.opencontainers.image.licenses="Apache-2.0" +LABEL org.opencontainers.image.title="Chocolatey" +LABEL org.opencontainers.image.description="Chocolatey Client running on Mono" +LABEL org.opencontainers.image.authors="https://chocolatey.org/support" +LABEL org.opencontainers.image.base.name="index.docker.io/library/mono:${monoversion}" -WORKDIR /usr/local/bin -RUN ln -s /usr/local/src/choco/code_drop/chocolatey +ENV ChocolateyInstall /opt/chocolatey -COPY docker/choco_wrapper /usr/local/bin/choco +COPY --from=build /usr/local/src/choco/code_drop/chocolatey/console /opt/chocolatey -ENV ChocolateyInstall /usr/local/bin/chocolatey +RUN mkdir /opt/chocolatey/lib; \ + cp /opt/chocolatey/choco_wrapper usr/local/bin/choco; \ + cp /opt/chocolatey/choco_wrapper usr/local/bin/choco.exe; WORKDIR /root diff --git a/docker/README.md b/docker/README.md index 504a96261a..fd6599ae81 100644 --- a/docker/README.md +++ b/docker/README.md @@ -8,5 +8,9 @@ To build this image yourself, follow these steps: 1. Clone down the repository using `git clone https://github.com/chocolatey/choco.git`. 1. Change directories to the root of the repository. 1. Run the docker build command. `docker build -t mono-choco -f docker/Dockerfile.linux .` (the trailing . is important) + To build a official version, add the argument `--build-arg buildscript=build.official.sh` + To build a debug version, add the argument `--build-arg buildscript=build.official.sh` + To change the version of mono used, add the argument `--build-arg monoversion=mono-tag` 1. Run your new image using the command `docker run -ti --rm mono-choco /bin/bash` 1. Test choco by running `choco -h`. You should see the help message from choco.exe. + diff --git a/docker/choco_official_wrapper b/docker/choco_official_wrapper new file mode 100644 index 0000000000..6005de42d5 --- /dev/null +++ b/docker/choco_official_wrapper @@ -0,0 +1,3 @@ +#!/bin/bash + +mono /opt/chocolatey/choco.exe "$@" diff --git a/docker/choco_wrapper b/docker/choco_wrapper index 745cdf43ce..881390888f 100755 --- a/docker/choco_wrapper +++ b/docker/choco_wrapper @@ -1,3 +1,3 @@ #!/bin/bash -mono /usr/local/bin/chocolatey/console/choco.exe "$@" --allow-unofficial +mono /opt/chocolatey/choco.exe "$@" --allow-unofficial