-
-
Save agustinmista/26c09b128c69c298f98477255c26e64c to your computer and use it in GitHub Desktop.
Self-installing binaries using Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BIN_NAME=alex | |
| USER_NAME=`id -un` | |
| USER_UID=`id -g` | |
| USER_GID=`id -g` | |
| if [[ "$(docker images -q $BIN_NAME 2> /dev/null)" == "" ]]; then | |
| docker build -t $BIN_NAME -f . - <<EOF | |
| FROM haskell:9.0 | |
| RUN groupadd --gid $USER_GID $USER_NAME | |
| RUN useradd -m --uid $USER_UID --gid $USER_GID $USER_NAME | |
| USER $USER_NAME | |
| RUN cabal update && \ | |
| cabal install $BIN_NAME | |
| ENV PATH /home/$USER_NAME/.cabal/bin:$PATH | |
| WORKDIR "workdir" | |
| ENTRYPOINT ["$BIN_NAME"] | |
| EOF | |
| fi | |
| docker run -it --rm \ | |
| -v "$PWD:/home/$USER_NAME/workdir" \ | |
| -u $USER_GID \ | |
| $BIN_NAME "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment