|
| 1 | +ARG BUILD_ON_IMAGE=glcr.b-data.ch/ghc/ghc-musl |
| 2 | +ARG GHC_VERSION=latest |
| 3 | +ARG HLS_VERSION |
| 4 | +ARG STACK_VERSION |
| 5 | + |
| 6 | +ARG HLS_GHC_VERSION=${HLS_VERSION:+$GHC_VERSION} |
| 7 | +ARG HLS_SFX=/${HLS_GHC_VERSION:-all}/hls:${HLS_VERSION:-none} |
| 8 | + |
| 9 | +ARG STACK_VERSION_OVERRIDE=${STACK_VERSION:-none} |
| 10 | + |
| 11 | +FROM ${BUILD_ON_IMAGE}:${GHC_VERSION} as files |
| 12 | + |
| 13 | +RUN mkdir /files |
| 14 | + |
| 15 | +COPY conf /files |
| 16 | +COPY scripts /files |
| 17 | + |
| 18 | +## Ensure file modes are correct |
| 19 | +RUN find /files -type d -exec chmod 755 {} \; \ |
| 20 | + && find /files -type f -exec chmod 644 {} \; \ |
| 21 | + && find /files/usr/local/bin -type f -exec chmod 755 {} \; |
| 22 | + |
| 23 | +FROM glcr.b-data.ch/commercialhaskell/ssi:${STACK_VERSION_OVERRIDE} as ssi |
| 24 | + |
| 25 | +FROM ${BUILD_ON_IMAGE}${HLS_SFX} as hls |
| 26 | + |
| 27 | +FROM glcr.b-data.ch/ndmitchell/hlsi:latest as hlsi |
| 28 | + |
| 29 | +FROM docker.io/koalaman/shellcheck:stable as sci |
| 30 | + |
| 31 | +FROM ${BUILD_ON_IMAGE}:${GHC_VERSION} |
| 32 | + |
| 33 | +COPY --from=files /files / |
| 34 | + |
| 35 | +RUN sysArch="$(uname -m)" \ |
| 36 | + ## Ensure that common CA certificates |
| 37 | + ## and OpenSSL libraries are up to date |
| 38 | + && apk upgrade --no-cache ca-certificates openssl-dev \ |
| 39 | + ## Install yamllint |
| 40 | + && apk add --no-cache yamllint \ |
| 41 | + ## Install pip |
| 42 | + && apk add --no-cache py3-pip \ |
| 43 | + ## Install terminal multiplexers |
| 44 | + && apk add --no-cache screen tmux \ |
| 45 | + ## Install hadolint |
| 46 | + && case "$sysArch" in \ |
| 47 | + x86_64) tarArch="x86_64" ;; \ |
| 48 | + aarch64) tarArch="arm64" ;; \ |
| 49 | + *) echo "error: Architecture $sysArch unsupported"; exit 1 ;; \ |
| 50 | + esac \ |
| 51 | + && apiResponse="$(curl -sSL \ |
| 52 | + https://api.github.com/repos/hadolint/hadolint/releases/latest)" \ |
| 53 | + && downloadUrl="$(echo "$apiResponse" | grep -e \ |
| 54 | + "browser_download_url.*Linux-$tarArch\"" | cut -d : -f 2,3 | tr -d \")" \ |
| 55 | + && echo "$downloadUrl" | xargs curl -sSLo /usr/local/bin/hadolint \ |
| 56 | + && chmod 755 /usr/local/bin/hadolint \ |
| 57 | + ## Create folders in root directory |
| 58 | + && mkdir -p /root/.local/bin \ |
| 59 | + ## Create folders in skeleton directory |
| 60 | + && mkdir -p /etc/skel/.local/bin |
| 61 | + |
| 62 | +## Update environment |
| 63 | +ARG USE_ZSH_FOR_ROOT |
| 64 | +ARG SET_LANG |
| 65 | +ARG SET_TZ |
| 66 | + |
| 67 | +ENV TZ=${SET_TZ:-$TZ} \ |
| 68 | + LANG=${SET_LANG:-$LANG} |
| 69 | + |
| 70 | + ## Change root's shell to ZSH |
| 71 | +RUN if [ -n "$USE_ZSH_FOR_ROOT" ]; then \ |
| 72 | + apk add --no-cache zsh shadow; \ |
| 73 | + fix-chsh.sh; \ |
| 74 | + chsh -s /bin/zsh; \ |
| 75 | + fi \ |
| 76 | + ## Update timezone if needed |
| 77 | + && if [ "$TZ" != "" ]; then \ |
| 78 | + apk add --no-cache tzdata; \ |
| 79 | + echo "Setting TZ to $TZ"; \ |
| 80 | + ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime \ |
| 81 | + && echo "$TZ" > /etc/timezone; \ |
| 82 | + fi \ |
| 83 | + ## Add/Update locale if needed |
| 84 | + && if [ "$LANG" != "C.UTF-8" ]; then \ |
| 85 | + if [ -n "$LANG" ]; then \ |
| 86 | + apk add --no-cache musl-locales musl-locales-lang; \ |
| 87 | + fi; \ |
| 88 | + sed -i "s/LANG=C.UTF-8/LANG=$LANG/" /etc/profile.d/*locale.sh; \ |
| 89 | + sed -i "s/LANG:-C.UTF-8/LANG:-$LANG/" /etc/profile.d/*locale.sh; \ |
| 90 | + sed -i "s/LC_COLLATE=C/LC_COLLATE=$LANG/" /etc/profile.d/*locale.sh; \ |
| 91 | + sed -i "s/LC_COLLATE:-C/LC_COLLATE:-$LANG/" /etc/profile.d/*locale.sh; \ |
| 92 | + fi |
| 93 | + |
| 94 | +## Copy binaries as late as possible to avoid cache busting |
| 95 | +## Install Stack |
| 96 | +COPY --from=ssi /usr/local /usr/local |
| 97 | +## Install HLS |
| 98 | +COPY --from=hls /usr/local /usr/local |
| 99 | +## Install HLint |
| 100 | +COPY --from=hlsi /usr/local /usr/local |
| 101 | +## Install ShellCheck |
| 102 | +COPY --from=sci --chown=root:root /bin/shellcheck /usr/local/bin |
| 103 | + |
| 104 | +ARG HLS_VERSION |
| 105 | +ARG STACK_VERSION |
| 106 | + |
| 107 | +ARG STACK_VERSION_OVERRIDE=${STACK_VERSION} |
| 108 | + |
| 109 | +ENV HLS_VERSION=${HLS_VERSION} \ |
| 110 | + STACK_VERSION=${STACK_VERSION_OVERRIDE:-$STACK_VERSION} |
| 111 | + |
| 112 | +RUN if [ "${GHC_VERSION%.*}" = "9.2" ]; then \ |
| 113 | + if [ -f /usr/local/bin/stack ]; then \ |
| 114 | + mv -f /usr/local/bin/stack /usr/bin/; \ |
| 115 | + fi \ |
| 116 | + fi |
0 commit comments