├── .devcontainer ├── Dockerfile ├── devcontainer.json └── library-scripts │ ├── README.md │ └── common-debian.sh ├── .github └── workflows │ └── ma.yml ├── APKBUILD.in ├── Dockerfile.apk ├── Dockerfile.deb ├── Makefile ├── README.md ├── apk-vars.sh ├── generate-release.sh ├── install-ocaml.sh └── install-tools.sh /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ocaml/opam:debian-11-ocaml-4.14 as opam 2 | RUN opam-2.1 pin add -n odoc --dev 3 | RUN opam-2.1 install --confirm-level=unsafe-yes dune ocaml-lsp-server opam-monorepo ocamlformat.0.24.1 dune-release odoc mdx 4 | # Use the [Choice] comment to indicate option arguments that should appear in VS Code UX. Use a comma separated list. 5 | # 6 | # [Choice] Debian OS version: bullseye 7 | FROM buildpack-deps:bullseye-curl 8 | # Use the [Option] comment to specify true/false arguments that should appear in VS Code UX 9 | # 10 | # [Option] Install zsh 11 | ARG INSTALL_ZSH="true" 12 | # [Option] Upgrade OS packages to their latest versions 13 | ARG UPGRADE_PACKAGES="false" 14 | 15 | # Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. 16 | ARG USERNAME=vscode 17 | ARG USER_UID=1000 18 | ARG USER_GID=$USER_UID 19 | COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/ 20 | RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 21 | && /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true"\ 22 | && apt-get -y install build-essential curl \ 23 | && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts 24 | RUN cd /root && curl -OL https://github.com/ocaml/ocaml/archive/refs/tags/4.14.0.tar.gz && tar -xf 4.14.0.tar.gz && cd ocaml-4.14.0 && ./configure --prefix=/usr && make -j world.opt && make install && cd / && rm -f /root/4.14.0.tar.gz && rm -rf /root/ocaml-4.14.0 25 | COPY --from=opam /usr/bin/opam-2.1 /usr/bin/opam 26 | COPY --from=opam /home/opam/.opam/4.14/bin/dune /usr/bin/dune 27 | COPY --from=opam /home/opam/.opam/4.14/bin/ocamllsp /usr/bin/ocamllsp 28 | COPY --from=opam /home/opam/.opam/4.14/bin/opam-monorepo /usr/bin/opam-monorepo 29 | COPY --from=opam /home/opam/.opam/4.14/bin/odoc /usr/bin/odoc 30 | COPY --from=opam /home/opam/.opam/4.14/bin/ocaml-mdx /usr/bin/ocaml-mdx 31 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Your Definition Name Here (Community)", 3 | 4 | // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. 5 | "build": { 6 | "dockerfile": "Dockerfile", 7 | // [Optional] You can use build args to set options. e.g. 'VARIANT' below affects the image in the Dockerfile 8 | "args": { "VARIANT": "buster" } 9 | }, 10 | 11 | // Set *default* container specific settings.json values on container create. 12 | "settings": {}, 13 | 14 | // Add the IDs of extensions you want installed when the container is created. 15 | "extensions": [], 16 | 17 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 18 | // "forwardPorts": [], 19 | 20 | // Use 'postCreateCommand' to run commands after the container is created. 21 | // "postCreateCommand": "uname -a", 22 | 23 | // Uncomment to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. 24 | // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], 25 | 26 | // Uncomment when using a ptrace-based debugger like C++, Go, and Rust 27 | // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], 28 | 29 | // Comment out to connect as root instead. To add a non-root user, see: https://aka.ms/vscode-remote/containers/non-root. 30 | "remoteUser": "vscode" 31 | } 32 | -------------------------------------------------------------------------------- /.devcontainer/library-scripts/README.md: -------------------------------------------------------------------------------- 1 | # Warning: Folder contents may be replaced 2 | 3 | The contents of this folder will be automatically replaced with a file of the same name in the [vscode-dev-containers](https://github.com/microsoft/vscode-dev-containers) repository's [script-library folder](https://github.com/microsoft/vscode-dev-containers/tree/main/script-library) whenever the repository is packaged. To retain your edits, move the file to a different location. You may also delete the files if they are not needed. 4 | 5 | ## Adding a new script from the script-library folder 6 | 7 | When creating a dev container for the vscode-dev-containers repository, simply drop a copy of the script you want to use from the [script-library folder](https://github.com/microsoft/vscode-dev-containers/tree/main/script-library) into this folder and it will be automatically kept up to date as things change. 8 | -------------------------------------------------------------------------------- /.devcontainer/library-scripts/common-debian.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #------------------------------------------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. 5 | #------------------------------------------------------------------------------------------------------------- 6 | # 7 | # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md 8 | # Maintainer: The VS Code and Codespaces Teams 9 | # 10 | # Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] [Add non-free packages] 11 | 12 | set -e 13 | 14 | INSTALL_ZSH=${1:-"true"} 15 | USERNAME=${2:-"automatic"} 16 | USER_UID=${3:-"automatic"} 17 | USER_GID=${4:-"automatic"} 18 | UPGRADE_PACKAGES=${5:-"true"} 19 | INSTALL_OH_MYS=${6:-"true"} 20 | ADD_NON_FREE_PACKAGES=${7:-"false"} 21 | SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)" 22 | MARKER_FILE="/usr/local/etc/vscode-dev-containers/common" 23 | 24 | if [ "$(id -u)" -ne 0 ]; then 25 | echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' 26 | exit 1 27 | fi 28 | 29 | # Ensure that login shells get the correct path if the user updated the PATH using ENV. 30 | rm -f /etc/profile.d/00-restore-env.sh 31 | echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh 32 | chmod +x /etc/profile.d/00-restore-env.sh 33 | 34 | # If in automatic mode, determine if a user already exists, if not use vscode 35 | if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then 36 | USERNAME="" 37 | POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") 38 | for CURRENT_USER in ${POSSIBLE_USERS[@]}; do 39 | if id -u ${CURRENT_USER} > /dev/null 2>&1; then 40 | USERNAME=${CURRENT_USER} 41 | break 42 | fi 43 | done 44 | if [ "${USERNAME}" = "" ]; then 45 | USERNAME=vscode 46 | fi 47 | elif [ "${USERNAME}" = "none" ]; then 48 | USERNAME=root 49 | USER_UID=0 50 | USER_GID=0 51 | fi 52 | 53 | # Load markers to see which steps have already run 54 | if [ -f "${MARKER_FILE}" ]; then 55 | echo "Marker file found:" 56 | cat "${MARKER_FILE}" 57 | source "${MARKER_FILE}" 58 | fi 59 | 60 | # Ensure apt is in non-interactive to avoid prompts 61 | export DEBIAN_FRONTEND=noninteractive 62 | 63 | # Function to call apt-get if needed 64 | apt_get_update_if_needed() 65 | { 66 | if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then 67 | echo "Running apt-get update..." 68 | apt-get update 69 | else 70 | echo "Skipping apt-get update." 71 | fi 72 | } 73 | 74 | # Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies 75 | if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then 76 | 77 | package_list="apt-utils \ 78 | openssh-client \ 79 | gnupg2 \ 80 | dirmngr \ 81 | iproute2 \ 82 | procps \ 83 | lsof \ 84 | htop \ 85 | net-tools \ 86 | psmisc \ 87 | curl \ 88 | wget \ 89 | rsync \ 90 | ca-certificates \ 91 | unzip \ 92 | zip \ 93 | nano \ 94 | vim-tiny \ 95 | less \ 96 | jq \ 97 | lsb-release \ 98 | apt-transport-https \ 99 | dialog \ 100 | libc6 \ 101 | libgcc1 \ 102 | libkrb5-3 \ 103 | libgssapi-krb5-2 \ 104 | libicu[0-9][0-9] \ 105 | liblttng-ust0 \ 106 | libstdc++6 \ 107 | zlib1g \ 108 | locales \ 109 | sudo \ 110 | ncdu \ 111 | man-db \ 112 | strace \ 113 | manpages \ 114 | manpages-dev \ 115 | init-system-helpers" 116 | 117 | # Needed for adding manpages-posix and manpages-posix-dev which are non-free packages in Debian 118 | if [ "${ADD_NON_FREE_PACKAGES}" = "true" ]; then 119 | # Bring in variables from /etc/os-release like VERSION_CODENAME 120 | . /etc/os-release 121 | sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME} main contrib non-free/" /etc/apt/sources.list 122 | sed -i -E "s/deb-src http:\/\/(deb|httredir)\.debian\.org\/debian ${VERSION_CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME} main contrib non-free/" /etc/apt/sources.list 123 | sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list 124 | sed -i -E "s/deb-src http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list 125 | sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list 126 | sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list 127 | sed -i "s/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list 128 | sed -i "s/deb-src http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list 129 | # Handle bullseye location for security https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html 130 | sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list 131 | sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list 132 | echo "Running apt-get update..." 133 | apt-get update 134 | package_list="${package_list} manpages-posix manpages-posix-dev" 135 | else 136 | apt_get_update_if_needed 137 | fi 138 | 139 | # Install libssl1.1 if available 140 | if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then 141 | package_list="${package_list} libssl1.1" 142 | fi 143 | 144 | # Install appropriate version of libssl1.0.x if available 145 | libssl_package=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '') 146 | if [ "$(echo "$LIlibssl_packageBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then 147 | if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then 148 | # Debian 9 149 | package_list="${package_list} libssl1.0.2" 150 | elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then 151 | # Ubuntu 18.04, 16.04, earlier 152 | package_list="${package_list} libssl1.0.0" 153 | fi 154 | fi 155 | 156 | echo "Packages to verify are installed: ${package_list}" 157 | apt-get -y install --no-install-recommends ${package_list} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 ) 158 | 159 | # Install git if not already installed (may be more recent than distro version) 160 | if ! type git > /dev/null 2>&1; then 161 | apt-get -y install --no-install-recommends git 162 | fi 163 | 164 | PACKAGES_ALREADY_INSTALLED="true" 165 | fi 166 | 167 | # Get to latest versions of all packages 168 | if [ "${UPGRADE_PACKAGES}" = "true" ]; then 169 | apt_get_update_if_needed 170 | apt-get -y upgrade --no-install-recommends 171 | apt-get autoremove -y 172 | fi 173 | 174 | # Ensure at least the en_US.UTF-8 UTF-8 locale is available. 175 | # Common need for both applications and things like the agnoster ZSH theme. 176 | if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then 177 | echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen 178 | locale-gen 179 | LOCALE_ALREADY_SET="true" 180 | fi 181 | 182 | # Create or update a non-root user to match UID/GID. 183 | group_name="${USERNAME}" 184 | if id -u ${USERNAME} > /dev/null 2>&1; then 185 | # User exists, update if needed 186 | if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then 187 | group_name="$(id -gn $USERNAME)" 188 | groupmod --gid $USER_GID ${group_name} 189 | usermod --gid $USER_GID $USERNAME 190 | fi 191 | if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then 192 | usermod --uid $USER_UID $USERNAME 193 | fi 194 | else 195 | # Create user 196 | if [ "${USER_GID}" = "automatic" ]; then 197 | groupadd $USERNAME 198 | else 199 | groupadd --gid $USER_GID $USERNAME 200 | fi 201 | if [ "${USER_UID}" = "automatic" ]; then 202 | useradd -s /bin/bash --gid $USERNAME -m $USERNAME 203 | else 204 | useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME 205 | fi 206 | fi 207 | 208 | # Add sudo support for non-root user 209 | if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then 210 | echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME 211 | chmod 0440 /etc/sudoers.d/$USERNAME 212 | EXISTING_NON_ROOT_USER="${USERNAME}" 213 | fi 214 | 215 | # ** Shell customization section ** 216 | if [ "${USERNAME}" = "root" ]; then 217 | user_rc_path="/root" 218 | else 219 | user_rc_path="/home/${USERNAME}" 220 | fi 221 | 222 | # Restore user .bashrc defaults from skeleton file if it doesn't exist or is empty 223 | if [ ! -f "${user_rc_path}/.bashrc" ] || [ ! -s "${user_rc_path}/.bashrc" ] ; then 224 | cp /etc/skel/.bashrc "${user_rc_path}/.bashrc" 225 | fi 226 | 227 | # Restore user .profile defaults from skeleton file if it doesn't exist or is empty 228 | if [ ! -f "${user_rc_path}/.profile" ] || [ ! -s "${user_rc_path}/.profile" ] ; then 229 | cp /etc/skel/.profile "${user_rc_path}/.profile" 230 | fi 231 | 232 | # .bashrc/.zshrc snippet 233 | rc_snippet="$(cat << 'EOF' 234 | 235 | if [ -z "${USER}" ]; then export USER=$(whoami); fi 236 | if [[ "${PATH}" != *"$HOME/.local/bin"* ]]; then export PATH="${PATH}:$HOME/.local/bin"; fi 237 | 238 | # Display optional first run image specific notice if configured and terminal is interactive 239 | if [ -t 1 ] && [[ "${TERM_PROGRAM}" = "vscode" || "${TERM_PROGRAM}" = "codespaces" ]] && [ ! -f "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed" ]; then 240 | if [ -f "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" ]; then 241 | cat "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" 242 | elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then 243 | cat "/workspaces/.codespaces/shared/first-run-notice.txt" 244 | fi 245 | mkdir -p "$HOME/.config/vscode-dev-containers" 246 | # Mark first run notice as displayed after 10s to avoid problems with fast terminal refreshes hiding it 247 | ((sleep 10s; touch "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed") &) 248 | fi 249 | 250 | # Set the default git editor if not already set 251 | if [ -z "$(git config --get core.editor)" ] && [ -z "${GIT_EDITOR}" ]; then 252 | if [ "${TERM_PROGRAM}" = "vscode" ]; then 253 | if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then 254 | export GIT_EDITOR="code-insiders --wait" 255 | else 256 | export GIT_EDITOR="code --wait" 257 | fi 258 | fi 259 | fi 260 | 261 | EOF 262 | )" 263 | 264 | # code shim, it fallbacks to code-insiders if code is not available 265 | cat << 'EOF' > /usr/local/bin/code 266 | #!/bin/sh 267 | 268 | get_in_path_except_current() { 269 | which -a "$1" | grep -A1 "$0" | grep -v "$0" 270 | } 271 | 272 | code="$(get_in_path_except_current code)" 273 | 274 | if [ -n "$code" ]; then 275 | exec "$code" "$@" 276 | elif [ "$(command -v code-insiders)" ]; then 277 | exec code-insiders "$@" 278 | else 279 | echo "code or code-insiders is not installed" >&2 280 | exit 127 281 | fi 282 | EOF 283 | chmod +x /usr/local/bin/code 284 | 285 | # systemctl shim - tells people to use 'service' if systemd is not running 286 | cat << 'EOF' > /usr/local/bin/systemctl 287 | #!/bin/sh 288 | set -e 289 | if [ -d "/run/systemd/system" ]; then 290 | exec /bin/systemctl "$@" 291 | else 292 | echo '\n"systemd" is not running in this container due to its overhead.\nUse the "service" command to start services instead. e.g.: \n\nservice --status-all' 293 | fi 294 | EOF 295 | chmod +x /usr/local/bin/systemctl 296 | 297 | # Codespaces bash and OMZ themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme 298 | codespaces_bash="$(cat \ 299 | <<'EOF' 300 | 301 | # Codespaces bash prompt theme 302 | __bash_prompt() { 303 | local userpart='`export XIT=$? \ 304 | && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \ 305 | && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`' 306 | local gitbranch='`\ 307 | if [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \ 308 | export BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null); \ 309 | if [ "${BRANCH}" != "" ]; then \ 310 | echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \ 311 | && if git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \ 312 | echo -n " \[\033[1;33m\]✗"; \ 313 | fi \ 314 | && echo -n "\[\033[0;36m\]) "; \ 315 | fi; \ 316 | fi`' 317 | local lightblue='\[\033[1;34m\]' 318 | local removecolor='\[\033[0m\]' 319 | PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ " 320 | unset -f __bash_prompt 321 | } 322 | __bash_prompt 323 | 324 | EOF 325 | )" 326 | 327 | codespaces_zsh="$(cat \ 328 | <<'EOF' 329 | # Codespaces zsh prompt theme 330 | __zsh_prompt() { 331 | local prompt_username 332 | if [ ! -z "${GITHUB_USER}" ]; then 333 | prompt_username="@${GITHUB_USER}" 334 | else 335 | prompt_username="%n" 336 | fi 337 | PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}➜ :%{$fg_bold[red]%}➜ )" # User/exit code arrow 338 | PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} ' # cwd 339 | PROMPT+='$([ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ] && git_prompt_info)' # Git status 340 | PROMPT+='%{$fg[white]%}$ %{$reset_color%}' 341 | unset -f __zsh_prompt 342 | } 343 | ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}(%{$fg_bold[red]%}" 344 | ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " 345 | ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[yellow]%}✗%{$fg_bold[cyan]%})" 346 | ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[cyan]%})" 347 | __zsh_prompt 348 | 349 | EOF 350 | )" 351 | 352 | # Add RC snippet and custom bash prompt 353 | if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then 354 | echo "${rc_snippet}" >> /etc/bash.bashrc 355 | echo "${codespaces_bash}" >> "${user_rc_path}/.bashrc" 356 | echo 'export PROMPT_DIRTRIM=4' >> "${user_rc_path}/.bashrc" 357 | if [ "${USERNAME}" != "root" ]; then 358 | echo "${codespaces_bash}" >> "/root/.bashrc" 359 | echo 'export PROMPT_DIRTRIM=4' >> "/root/.bashrc" 360 | fi 361 | chown ${USERNAME}:${group_name} "${user_rc_path}/.bashrc" 362 | RC_SNIPPET_ALREADY_ADDED="true" 363 | fi 364 | 365 | # Optionally install and configure zsh and Oh My Zsh! 366 | if [ "${INSTALL_ZSH}" = "true" ]; then 367 | if ! type zsh > /dev/null 2>&1; then 368 | apt_get_update_if_needed 369 | apt-get install -y zsh 370 | fi 371 | if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then 372 | echo "${rc_snippet}" >> /etc/zsh/zshrc 373 | ZSH_ALREADY_INSTALLED="true" 374 | fi 375 | 376 | # Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme. 377 | # See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script. 378 | oh_my_install_dir="${user_rc_path}/.oh-my-zsh" 379 | if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then 380 | template_path="${oh_my_install_dir}/templates/zshrc.zsh-template" 381 | user_rc_file="${user_rc_path}/.zshrc" 382 | umask g-w,o-w 383 | mkdir -p ${oh_my_install_dir} 384 | git clone --depth=1 \ 385 | -c core.eol=lf \ 386 | -c core.autocrlf=false \ 387 | -c fsck.zeroPaddedFilemode=ignore \ 388 | -c fetch.fsck.zeroPaddedFilemode=ignore \ 389 | -c receive.fsck.zeroPaddedFilemode=ignore \ 390 | "https://github.com/ohmyzsh/ohmyzsh" "${oh_my_install_dir}" 2>&1 391 | echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file} 392 | sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${user_rc_file} 393 | 394 | mkdir -p ${oh_my_install_dir}/custom/themes 395 | echo "${codespaces_zsh}" > "${oh_my_install_dir}/custom/themes/codespaces.zsh-theme" 396 | # Shrink git while still enabling updates 397 | cd "${oh_my_install_dir}" 398 | git repack -a -d -f --depth=1 --window=1 399 | # Copy to non-root user if one is specified 400 | if [ "${USERNAME}" != "root" ]; then 401 | cp -rf "${user_rc_file}" "${oh_my_install_dir}" /root 402 | chown -R ${USERNAME}:${group_name} "${user_rc_path}" 403 | fi 404 | fi 405 | fi 406 | 407 | # Persist image metadata info, script if meta.env found in same directory 408 | meta_info_script="$(cat << 'EOF' 409 | #!/bin/sh 410 | . /usr/local/etc/vscode-dev-containers/meta.env 411 | 412 | # Minimal output 413 | if [ "$1" = "version" ] || [ "$1" = "image-version" ]; then 414 | echo "${VERSION}" 415 | exit 0 416 | elif [ "$1" = "release" ]; then 417 | echo "${GIT_REPOSITORY_RELEASE}" 418 | exit 0 419 | elif [ "$1" = "content" ] || [ "$1" = "content-url" ] || [ "$1" = "contents" ] || [ "$1" = "contents-url" ]; then 420 | echo "${CONTENTS_URL}" 421 | exit 0 422 | fi 423 | 424 | #Full output 425 | echo 426 | echo "Development container image information" 427 | echo 428 | if [ ! -z "${VERSION}" ]; then echo "- Image version: ${VERSION}"; fi 429 | if [ ! -z "${DEFINITION_ID}" ]; then echo "- Definition ID: ${DEFINITION_ID}"; fi 430 | if [ ! -z "${VARIANT}" ]; then echo "- Variant: ${VARIANT}"; fi 431 | if [ ! -z "${GIT_REPOSITORY}" ]; then echo "- Source code repository: ${GIT_REPOSITORY}"; fi 432 | if [ ! -z "${GIT_REPOSITORY_RELEASE}" ]; then echo "- Source code release/branch: ${GIT_REPOSITORY_RELEASE}"; fi 433 | if [ ! -z "${BUILD_TIMESTAMP}" ]; then echo "- Timestamp: ${BUILD_TIMESTAMP}"; fi 434 | if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; fi 435 | echo 436 | EOF 437 | )" 438 | if [ -f "${SCRIPT_DIR}/meta.env" ]; then 439 | mkdir -p /usr/local/etc/vscode-dev-containers/ 440 | cp -f "${SCRIPT_DIR}/meta.env" /usr/local/etc/vscode-dev-containers/meta.env 441 | echo "${meta_info_script}" > /usr/local/bin/devcontainer-info 442 | chmod +x /usr/local/bin/devcontainer-info 443 | fi 444 | 445 | # Write marker file 446 | mkdir -p "$(dirname "${MARKER_FILE}")" 447 | echo -e "\ 448 | PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\ 449 | LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\ 450 | EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\ 451 | RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\ 452 | ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}" 453 | 454 | echo "Done!" 455 | -------------------------------------------------------------------------------- /.github/workflows/ma.yml: -------------------------------------------------------------------------------- 1 | name: BuildJet workflow 2 | 3 | on: 4 | push: 5 | 6 | env: 7 | REGISTRY: ghcr.io 8 | IMAGE_NAME: ${{ github.repository }} 9 | 10 | jobs: 11 | build: 12 | strategy: 13 | matrix: 14 | runs-on: ['buildjet-32vcpu-ubuntu-2204-arm', 'buildjet-32vcpu-ubuntu-2204'] 15 | ocaml-version: ['4.14.1', '5.0.0', '5.1.0', '5.2.0'] 16 | runs-on: ${{ matrix.runs-on }} 17 | steps: 18 | - 19 | name: Detect architecture 20 | run: | 21 | if [ "${{ endswith(matrix.runs-on, 'arm') }}" = "true" ]; then 22 | echo "ARCH=arm64" >> $GITHUB_ENV 23 | else 24 | echo "ARCH=amd64" >> $GITHUB_ENV 25 | fi 26 | - 27 | name: Set up Docker Buildx 28 | uses: docker/setup-buildx-action@v2 29 | - 30 | name: Log in to the Container registry 31 | uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 32 | with: 33 | registry: ${{ env.REGISTRY }} 34 | username: ${{ github.actor }} 35 | password: ${{ secrets.GITHUB_TOKEN }} 36 | - 37 | name: Checkout 38 | uses: actions/checkout@v3 39 | - 40 | name: Build and push Debian repo 41 | id: build-deb 42 | uses: docker/build-push-action@master 43 | with: 44 | file: Dockerfile.deb 45 | build-args: | 46 | OCAML_VERSION=${{ matrix.ocaml-version }} 47 | outputs: | 48 | type=local,dest=/tmp/pkgs/deb 49 | - 50 | name: Build and push Alpine repo 51 | id: build-apk 52 | uses: docker/build-push-action@master 53 | with: 54 | file: Dockerfile.apk 55 | build-args: | 56 | OCAML_VERSION=${{ matrix.ocaml-version }} 57 | outputs: | 58 | type=local,dest=/tmp/pkgs/apk 59 | - name: Upload packages 60 | uses: actions/upload-artifact@v3 61 | with: 62 | name: debs-${{ matrix.ocaml-version}}-${{ env.ARCH }} 63 | path: /tmp/pkgs/deb 64 | retention-days: 1 65 | - name: Upload apks 66 | uses: actions/upload-artifact@v3 67 | with: 68 | name: apks-${{ matrix.ocaml-version}}-${{ env.ARCH }} 69 | path: /tmp/pkgs/apk 70 | retention-days: 1 71 | debs: 72 | runs-on: ubuntu-latest 73 | needs: build 74 | steps: 75 | - 76 | name: Set up Docker Buildx 77 | uses: docker/setup-buildx-action@v2 78 | - name: Download digests 79 | uses: actions/download-artifact@v3 80 | - name: Move debs to one directory 81 | run: | 82 | mkdir /tmp/debs 83 | for i in debs-*; do 84 | mv $i/*.deb /tmp/debs/ 85 | done 86 | - name: Upload debs to release 87 | uses: svenstaro/upload-release-action@v2 88 | with: 89 | repo_token: ${{ secrets.GITHUB_TOKEN }} 90 | file: /tmp/debs/*.deb 91 | tag: debs 92 | overwrite: true 93 | file_glob: true 94 | - name: Move APKs to one directory 95 | run: | 96 | mkdir /tmp/apks 97 | for i in apks-*; do 98 | mv $i/*.apk /tmp/apks/ 99 | done 100 | - name: Upload APKs to release 101 | uses: svenstaro/upload-release-action@v2 102 | with: 103 | repo_token: ${{ secrets.GITHUB_TOKEN }} 104 | file: /tmp/apks/*.apk 105 | tag: apks 106 | overwrite: true 107 | file_glob: true 108 | -------------------------------------------------------------------------------- /APKBUILD.in: -------------------------------------------------------------------------------- 1 | # Maintainer: Anil Madhavapeddy 2 | pkgname=ocaml-dev-tools 3 | pkgver=%OCAML_VERSION% 4 | pkgrel=%OCAML_DATE% 5 | pkgdesc="OCaml %OCAML_VERSION% compiler and associated development tools" 6 | url="https://github.com/avsm/ocaml-devcontainers" 7 | arch=%OCAML_ARCH% 8 | license="LGPL2" 9 | depends="" 10 | makedepends="" 11 | install="" 12 | subpackages="" 13 | source="ocaml-dev-tools.tar" 14 | 15 | build() { 16 | /bin/true 17 | } 18 | 19 | package() { 20 | mkdir -p $pkgdir 21 | cp -r $srcdir/usr $pkgdir 22 | } 23 | 24 | check() { 25 | /usr/dev/ocaml/bin/opam --version >/dev/null 26 | } 27 | -------------------------------------------------------------------------------- /Dockerfile.apk: -------------------------------------------------------------------------------- 1 | FROM ocaml/opam:alpine-3.18 as opam 2 | FROM alpine:3.18 as build 3 | ARG OCAML_VERSION=4.14.1 4 | ARG OCAML_PREFIX=/usr/dev/ocaml 5 | RUN apk add --update alpine-sdk build-base curl git bzip2 bash 6 | RUN mkdir -p ${OCAML_PREFIX}/bin ${OCAML_PREFIX}/lib 7 | COPY install-ocaml.sh /root/install-ocaml.sh 8 | RUN env PREFIX=${OCAML_PREFIX} /root/install-ocaml.sh ${OCAML_VERSION} 9 | COPY --from=opam /usr/bin/opam-2.1 ${OCAML_PREFIX}/bin/opam 10 | COPY --from=opam /usr/bin/opam-2.1 /tmp/installdir/${OCAML_PREFIX}/bin/opam 11 | COPY install-tools.sh /root/install-tools.sh 12 | RUN env PREFIX=${OCAML_PREFIX} /root/install-tools.sh ${OCAML_VERSION} 13 | RUN mkdir -p /root/ocaml-dev-tools 14 | RUN tar -C /tmp/installdir -cvf /root/ocaml-dev-tools/ocaml-dev-tools.tar . 15 | WORKDIR /root/ocaml-dev-tools 16 | COPY APKBUILD.in /root/ 17 | COPY apk-vars.sh /root/ 18 | RUN /root/apk-vars.sh /root/APKBUILD.in /root/ocaml-dev-tools/APKBUILD 19 | RUN env SUDO="" abuild-keygen -ani 20 | RUN abuild -F checksum 21 | RUN abuild -Fr 22 | RUN mkdir -p /out 23 | RUN cp /root/packages/root/`arch`/ocaml-dev-tools-*.apk /out/ocaml-dev-tools-${OCAML_VERSION}-`arch`.apk 24 | FROM scratch 25 | COPY --from=build /out/ / 26 | -------------------------------------------------------------------------------- /Dockerfile.deb: -------------------------------------------------------------------------------- 1 | FROM ocaml/opam:ubuntu-20.04 as opam 2 | FROM ubuntu:20.04 as build 3 | ARG OCAML_VERSION=4.14.1 4 | ARG OCAML_PREFIX=/usr/dev/ocaml 5 | RUN apt-get update && apt-get install -y ruby ruby-dev rubygems build-essential curl git bzip2 6 | RUN mkdir -p /tmp/installdir/usr/bin /tmp/installdir/usr/lib 7 | COPY install-ocaml.sh /root/install-ocaml.sh 8 | RUN env PREFIX=${OCAML_PREFIX} /root/install-ocaml.sh ${OCAML_VERSION} 9 | COPY --from=opam /usr/bin/opam-2.1 ${OCAML_PREFIX}/bin/opam 10 | COPY --from=opam /usr/bin/opam-2.1 /tmp/installdir/${OCAML_PREFIX}/bin/opam 11 | COPY install-tools.sh /root/install-tools.sh 12 | RUN env PREFIX=${OCAML_PREFIX} /root/install-tools.sh ${OCAML_VERSION} 13 | RUN gem install fpm 14 | RUN fpm -s dir -t deb -p ocaml-dev-tools_${OCAML_VERSION}_`dpkg --print-architecture`.deb --name ocaml-dev-tools --license lgpl2 --version ${OCAML_VERSION}~`date +%Y%m%d` --architecture `dpkg --print-architecture` --maintainer "Anil Madhavapeddy " -C /tmp/installdir . 15 | FROM scratch 16 | COPY --from=build /ocaml-dev-tools*.deb / 17 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all depends buildx push debs 2 | 3 | all: 4 | @. 5 | 6 | depends: 7 | docker run --privileged --rm tonistiigi/binfmt --install all 8 | 9 | buildx: 10 | docker buildx build --platform linux/arm64,linux/amd64 --tag avsm/ocaml-devcontainer:4.14 --pull . 11 | 12 | push: 13 | docker buildx build --push --platform linux/arm64,linux/amd64 --tag avsm/ocaml-devcontainer:4.14 --pull . 14 | 15 | debs: 16 | docker buildx build --push --platform linux/arm64,linux/amd64 --tag avsm/ocaml-devcontainer:4.14-debs -f Dockerfile.deb --pull . 17 | docker buildx build --push --platform linux/arm64,linux/amd64 --tag avsm/ocaml-devcontainer:debrepo -f Dockerfile.debrepo --pull . 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | An OCaml development container for VSCode 2 | 3 | Status: proof of concept 4 | 5 | -------------------------------------------------------------------------------- /apk-vars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ex 2 | 3 | sed -e "s,%OCAML_VERSION%,${OCAML_VERSION},g" \ 4 | -e "s,%OCAML_DATE%,`date +%Y%m%d`,g" \ 5 | -e "s,%OCAML_ARCH%,`arch`,g" < $1 > $2 6 | -------------------------------------------------------------------------------- /generate-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | do_hash() { 5 | HASH_NAME=$1 6 | HASH_CMD=$2 7 | echo "${HASH_NAME}:" 8 | for f in `find -type f`; do 9 | f=`echo $f | cut -c3-` 10 | if [ "$f" = "Release" ]; then 11 | continue 12 | fi 13 | echo " `${HASH_CMD} ${f} | cut -d" " -f1` `wc -c $f`" 14 | done 15 | } 16 | 17 | cat << EOF 18 | Origin: OCaml Development Tools Repository 19 | Label: OCaml 20 | Suite: stable 21 | Codename: stable 22 | Version: 1.0 23 | Architectures: amd64 arm64 24 | Components: main 25 | Description: OCaml development tools for devcontainers 26 | Date: `date -Ru` 27 | EOF 28 | do_hash "MD5Sum" "md5sum" 29 | do_hash "SHA1" "sha1sum" 30 | do_hash "SHA256" "sha256sum" 31 | 32 | -------------------------------------------------------------------------------- /install-ocaml.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | DESTDIR=${DESTDIR:-/tmp/installdir} 5 | PREFIX=${PREFIX:-/usr/local/ocaml} 6 | cd /root 7 | OCAML_VERSION=$1 8 | MODE=tags 9 | case ${OCAML_VERSION} in 10 | 5.2.0) 11 | OCAML_VERSION=trunk 12 | MODE=heads 13 | ;; 14 | 5.1.0) 15 | OCAML_VERSION=5.1 16 | MODE=heads 17 | ;; 18 | *) 19 | ;; 20 | esac 21 | curl -OL https://github.com/ocaml/ocaml/archive/refs/${MODE}/${OCAML_VERSION}.tar.gz 22 | tar -xf ${OCAML_VERSION}.tar.gz 23 | cd ocaml-${OCAML_VERSION} 24 | ./configure --prefix=${PREFIX} 25 | make -j world.opt >/dev/null 26 | make install DESTDIR=${DESTDIR} 27 | make install 28 | rm -f /root/${OCAML_VERSION}.tar.gz 29 | rm -rf /root/ocaml-${OCAML_VERSION} 30 | -------------------------------------------------------------------------------- /install-tools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | DESTDIR=${DESTDIR:-/tmp/installdir} 5 | PREFIX=${PREFIX:-/usr/local/ocaml} 6 | export PATH=$PATH:$PREFIX/bin 7 | cd /root 8 | 9 | OCAML_VERSION=$1 10 | 11 | opam init -ya --disable-sandboxing -c ocaml.${OCAML_VERSION} 12 | case ${OCAML_VERSION} in 13 | 5.2.0) 14 | TRUNK=1 15 | ;; 16 | 5.1.0) 17 | TRUNK=1 18 | ;; 19 | *) 20 | TRUNK=0 21 | ;; 22 | esac 23 | 24 | if [ "$TRUNK" = "0" ]; then 25 | opam install --confirm-level=unsafe-yes dune ocaml-lsp-server opam-monorepo ocamlformat dune-release odoc mdx 26 | mv /root/.opam/ocaml.${OCAML_VERSION}/bin/{dune,ocamllsp,opam-monorepo,ocamlformat,dune-release,odoc,ocaml-mdx} ${DESTDIR}/${PREFIX}/bin 27 | else 28 | opam install --confirm-level=unsafe-yes dune 29 | mv /root/.opam/ocaml.${OCAML_VERSION}/bin/dune ${DESTDIR}/${PREFIX}/bin 30 | fi 31 | --------------------------------------------------------------------------------