-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6228 from benz0li/add-dev-containers
Add Dev Container Configuration Files
- Loading branch information
Showing
17 changed files
with
592 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
* | ||
|
||
!/assets/ | ||
!/assets/cradles/ | ||
!/assets/cradles/cabal/ | ||
!/assets/cradles/stack/ | ||
!/assets/screenshots/ | ||
!/bind-mounts/ | ||
!/conf/ | ||
!/conf/etc/ | ||
!/conf/etc/stack/ | ||
!/ghc-*/ | ||
!/scripts/ | ||
!/scripts/usr/ | ||
!/scripts/usr/local/ | ||
!/scripts/usr/local/bin/ | ||
|
||
!/assets/cradles/cabal/hie.yaml | ||
!/assets/cradles/stack/hie.yaml | ||
!/assets/screenshots/manageHLS.png | ||
!/conf/etc/stack/config.yaml | ||
!/ghc-*/devcontainer.json | ||
!/scripts/usr/local/bin/*.sh | ||
|
||
!/devcontainer.json | ||
!/GHC.Dockerfile | ||
!/LICENSE | ||
!/README.md | ||
|
||
!.gitignore | ||
!.keep |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
ARG BUILD_ON_IMAGE=glcr.b-data.ch/ghc/ghc-musl | ||
ARG GHC_VERSION=latest | ||
ARG HLS_VERSION | ||
ARG STACK_VERSION | ||
|
||
ARG HLS_GHC_VERSION=${HLS_VERSION:+$GHC_VERSION} | ||
ARG HLS_SFX=/${HLS_GHC_VERSION:-all}/hls:${HLS_VERSION:-none} | ||
|
||
ARG STACK_VERSION_OVERRIDE=${STACK_VERSION:-none} | ||
|
||
FROM ${BUILD_ON_IMAGE}:${GHC_VERSION} as files | ||
|
||
RUN mkdir /files | ||
|
||
COPY conf /files | ||
COPY scripts /files | ||
|
||
## Ensure file modes are correct | ||
RUN find /files -type d -exec chmod 755 {} \; \ | ||
&& find /files -type f -exec chmod 644 {} \; \ | ||
&& find /files/usr/local/bin -type f -exec chmod 755 {} \; | ||
|
||
FROM glcr.b-data.ch/commercialhaskell/ssi:${STACK_VERSION_OVERRIDE} as ssi | ||
|
||
FROM ${BUILD_ON_IMAGE}${HLS_SFX} as hls | ||
|
||
FROM glcr.b-data.ch/ndmitchell/hlsi:latest as hlsi | ||
|
||
FROM docker.io/koalaman/shellcheck:stable as sci | ||
|
||
FROM ${BUILD_ON_IMAGE}:${GHC_VERSION} | ||
|
||
COPY --from=files /files / | ||
|
||
RUN sysArch="$(uname -m)" \ | ||
## Ensure that common CA certificates | ||
## and OpenSSL libraries are up to date | ||
&& apk upgrade --no-cache ca-certificates openssl-dev \ | ||
## Install yamllint | ||
&& apk add --no-cache yamllint \ | ||
## Install pip | ||
&& apk add --no-cache py3-pip \ | ||
## Install terminal multiplexers | ||
&& apk add --no-cache screen tmux \ | ||
## Install hadolint | ||
&& case "$sysArch" in \ | ||
x86_64) tarArch="x86_64" ;; \ | ||
aarch64) tarArch="arm64" ;; \ | ||
*) echo "error: Architecture $sysArch unsupported"; exit 1 ;; \ | ||
esac \ | ||
&& apiResponse="$(curl -sSL \ | ||
https://api.github.com/repos/hadolint/hadolint/releases/latest)" \ | ||
&& downloadUrl="$(echo "$apiResponse" | grep -e \ | ||
"browser_download_url.*Linux-$tarArch\"" | cut -d : -f 2,3 | tr -d \")" \ | ||
&& echo "$downloadUrl" | xargs curl -sSLo /usr/local/bin/hadolint \ | ||
&& chmod 755 /usr/local/bin/hadolint \ | ||
## Create folders in root directory | ||
&& mkdir -p /root/.local/bin \ | ||
## Create folders in skeleton directory | ||
&& mkdir -p /etc/skel/.local/bin | ||
|
||
## Update environment | ||
ARG USE_ZSH_FOR_ROOT | ||
ARG SET_LANG | ||
ARG SET_TZ | ||
|
||
ENV TZ=${SET_TZ:-$TZ} \ | ||
LANG=${SET_LANG:-$LANG} | ||
|
||
## Change root's shell to ZSH | ||
RUN if [ -n "$USE_ZSH_FOR_ROOT" ]; then \ | ||
apk add --no-cache zsh shadow; \ | ||
fix-chsh.sh; \ | ||
chsh -s /bin/zsh; \ | ||
fi \ | ||
## Update timezone if needed | ||
&& if [ "$TZ" != "" ]; then \ | ||
apk add --no-cache tzdata; \ | ||
echo "Setting TZ to $TZ"; \ | ||
ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime \ | ||
&& echo "$TZ" > /etc/timezone; \ | ||
fi \ | ||
## Add/Update locale if needed | ||
&& if [ "$LANG" != "C.UTF-8" ]; then \ | ||
if [ -n "$LANG" ]; then \ | ||
apk add --no-cache musl-locales musl-locales-lang; \ | ||
fi; \ | ||
sed -i "s/LANG=C.UTF-8/LANG=$LANG/" /etc/profile.d/*locale.sh; \ | ||
sed -i "s/LANG:-C.UTF-8/LANG:-$LANG/" /etc/profile.d/*locale.sh; \ | ||
sed -i "s/LC_COLLATE=C/LC_COLLATE=$LANG/" /etc/profile.d/*locale.sh; \ | ||
sed -i "s/LC_COLLATE:-C/LC_COLLATE:-$LANG/" /etc/profile.d/*locale.sh; \ | ||
fi | ||
|
||
## Copy binaries as late as possible to avoid cache busting | ||
## Install Stack | ||
COPY --from=ssi /usr/local /usr/local | ||
## Install HLS | ||
COPY --from=hls /usr/local /usr/local | ||
## Install HLint | ||
COPY --from=hlsi /usr/local /usr/local | ||
## Install ShellCheck | ||
COPY --from=sci --chown=root:root /bin/shellcheck /usr/local/bin | ||
|
||
ARG HLS_VERSION | ||
ARG STACK_VERSION | ||
|
||
ARG STACK_VERSION_OVERRIDE=${STACK_VERSION} | ||
|
||
ENV HLS_VERSION=${HLS_VERSION} \ | ||
STACK_VERSION=${STACK_VERSION_OVERRIDE:-$STACK_VERSION} | ||
|
||
RUN if [ "${GHC_VERSION%.*}" = "9.2" ]; then \ | ||
if [ -f /usr/local/bin/stack ]; then \ | ||
mv -f /usr/local/bin/stack /usr/bin/; \ | ||
fi \ | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Copyright (c) 2023 Olivier Benz | ||
|
||
The code in this directory is not part of Stack (the software) and, with the | ||
exceptions noted below, is distributed under the terms of the MIT License: | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
This directory also contains code with other copyrights. The affected files, | ||
their copyrights and license statements are listed below. | ||
|
||
-------------------------------------------------------------------------------- | ||
scripts/fix-chsh.sh | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
Licensed under the MIT License. See | ||
https://github.com/devcontainers/features/blob/main/LICENSE for | ||
license information. | ||
|
||
-------------------------------------------------------------------------------- |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Dev Containers | ||
|
||
See [haskellstack.org](https://docs.haskellstack.org): Stack's code (advanced) | ||
\> Maintainers \> Dev Containers or | ||
[../doc/maintainers/devcontainers.md](../doc/maintainers/devcontainers.md) | ||
for more information. | ||
|
||
## License | ||
|
||
The code in this directory is not part of Stack (the software) and, with the | ||
exceptions noted in [LICENSE](LICENSE), is distributed under the terms of the | ||
MIT License. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cradle: | ||
multi: | ||
- path: "./Setup.hs" | ||
config: | ||
cradle: | ||
direct: | ||
arguments: [] | ||
- path: "./" | ||
config: | ||
cradle: | ||
cabal: | ||
- path: "./src" | ||
component: "lib:stack" | ||
- path: "./app" | ||
component: "stack:exe:stack" | ||
- path: "./tests/integration" | ||
component: "stack:exe:stack-integration-test" | ||
- path: "./tests/unit" | ||
component: "stack:test:stack-unit-test" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cradle: | ||
multi: | ||
- path: "./Setup.hs" | ||
config: | ||
cradle: | ||
direct: | ||
arguments: [] | ||
- path: "./" | ||
config: | ||
cradle: | ||
stack: | ||
- path: "./src" | ||
component: "stack:lib" | ||
- path: "./app" | ||
component: "stack:exe:stack" | ||
- path: "./tests/integration" | ||
component: "stack:exe:stack-integration-test" | ||
- path: "./tests/unit" | ||
component: "stack:test:stack-unit-test" |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Use only the GHC available on the PATH | ||
system-ghc: true | ||
# Do not automatically install GHC when necessary | ||
install-ghc: false |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"name": "Default", | ||
"build": { | ||
"dockerfile": "GHC.Dockerfile", | ||
"args": { | ||
"GHC_VERSION": "9.4.6", | ||
"HLS_VERSION": "2.1.0.0", | ||
"USE_ZSH_FOR_ROOT": "unset-to-use-ash", | ||
"SET_LANG": "C.UTF-8", | ||
"SET_TZ": "" | ||
} | ||
}, | ||
|
||
"onCreateCommand": "onCreateCommand.sh", | ||
"postCreateCommand": "cabal update", | ||
|
||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"configureZshAsDefaultShell": true, | ||
"upgradePackages": false, | ||
"username": "vscode", | ||
"userUid": "automatic", | ||
"userGid": "automatic" | ||
} | ||
}, | ||
|
||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"[email protected]", | ||
"exiasr.hadolint", | ||
"GitHub.vscode-pull-request-github", | ||
"haskell.haskell", | ||
"mhutchie.git-graph", | ||
"mutantdino.resourcemonitor", | ||
"timonwong.shellcheck" | ||
], | ||
"settings": { | ||
"gitlens.showWelcomeOnInstall": false, | ||
"gitlens.showWhatsNewAfterUpgrades": false, | ||
"haskell.manageHLS": "PATH", | ||
"resmon.show.battery": false, | ||
"resmon.show.cpufreq": false | ||
} | ||
} | ||
}, | ||
|
||
// Set 'remoteUser' to 'root' to connect as root instead. | ||
"remoteUser": "vscode", | ||
"mounts": [ | ||
"source=stack-default-home-vscode,target=/home/vscode,type=volume" | ||
// "source=${localWorkspaceFolder}/.devcontainer/bind-mounts/stack-default-home-vscode,target=/home/vscode,type=bind" | ||
], | ||
|
||
// "remoteUser": "root", | ||
// "mounts": [ | ||
// "source=stack-default-root,target=/root,type=volume" | ||
// // "source=${localWorkspaceFolder}/.devcontainer/bind-mounts/stack-default-root,target=/root,type=bind" | ||
// ], | ||
|
||
// Pip: Install packages to the user site | ||
"remoteEnv": { | ||
"PIP_USER": "1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"name": "GHC 9.6.2", | ||
"build": { | ||
"dockerfile": "../GHC.Dockerfile", | ||
"context": "..", | ||
"args": { | ||
"GHC_VERSION": "9.6.2", | ||
"USE_ZSH_FOR_ROOT": "unset-to-use-ash", | ||
"SET_LANG": "C.UTF-8", | ||
"SET_TZ": "" | ||
} | ||
}, | ||
|
||
"onCreateCommand": "onCreateCommand.sh", | ||
"postCreateCommand": "cabal update", | ||
|
||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"configureZshAsDefaultShell": true, | ||
"upgradePackages": false, | ||
"username": "vscode", | ||
"userUid": "automatic", | ||
"userGid": "automatic" | ||
} | ||
}, | ||
|
||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"[email protected]", | ||
"exiasr.hadolint", | ||
"GitHub.vscode-pull-request-github", | ||
"mhutchie.git-graph", | ||
"mutantdino.resourcemonitor", | ||
"timonwong.shellcheck" | ||
], | ||
"settings": { | ||
"gitlens.showWelcomeOnInstall": false, | ||
"gitlens.showWhatsNewAfterUpgrades": false, | ||
"resmon.show.battery": false, | ||
"resmon.show.cpufreq": false | ||
} | ||
} | ||
}, | ||
|
||
// Set 'remoteUser' to 'root' to connect as root instead. | ||
"remoteUser": "vscode", | ||
"mounts": [ | ||
"source=stack-ghc-9.6.2-home-vscode,target=/home/vscode,type=volume" | ||
// "source=${localWorkspaceFolder}/.devcontainer/bind-mounts/stack-ghc-9.6.2-home-vscode,target=/home/vscode,type=bind" | ||
], | ||
|
||
// "remoteUser": "root", | ||
// "mounts": [ | ||
// "source=stack-ghc-9.6.2-root,target=/root,type=volume" | ||
// // "source=${localWorkspaceFolder}/.devcontainer/bind-mounts/stack-ghc-9.6.2-root,target=/root,type=bind" | ||
// ], | ||
|
||
// Pip: Install packages to the user site | ||
"remoteEnv": { | ||
"PIP_USER": "1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
#------------------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See https://github.com/devcontainers/features/blob/main/LICENSE for license information. | ||
#------------------------------------------------------------------------------------------------------------------------- | ||
# | ||
# Docs: https://github.com/devcontainers/features/tree/main/src/common-utils | ||
# Maintainer: The Dev Container spec maintainers | ||
|
||
set -e | ||
|
||
# Fixing chsh always asking for a password on alpine linux | ||
# ref: https://askubuntu.com/questions/812420/chsh-always-asking-a-password-and-get-pam-authentication-failure. | ||
if [ ! -f "/etc/pam.d/chsh" ] || ! grep -Eq '^auth(.*)pam_rootok\.so$' /etc/pam.d/chsh; then | ||
echo "auth sufficient pam_rootok.so" >> /etc/pam.d/chsh | ||
elif [[ -n "$(awk '/^auth(.*)pam_rootok\.so$/ && !/^auth[[:blank:]]+sufficient[[:blank:]]+pam_rootok\.so$/' /etc/pam.d/chsh)" ]]; then | ||
awk '/^auth(.*)pam_rootok\.so$/ { $2 = "sufficient" } { print }' /etc/pam.d/chsh > /tmp/chsh.tmp && mv /tmp/chsh.tmp /etc/pam.d/chsh | ||
fi |
Oops, something went wrong.