From 7181908908333c8c9584397173fa4cd7f6742a51 Mon Sep 17 00:00:00 2001 From: Michael Uti Date: Thu, 14 Nov 2024 20:02:47 +0100 Subject: [PATCH] ci: add dev container --- .devcontainer/Dockerfile | 64 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 19 ++++++++++ 2 files changed, 83 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..1cd1cc112f0 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,64 @@ +FROM mcr.microsoft.com/vscode/devcontainers/base:0.202.7-bullseye + +ARG NIX_VERSION=2.18.1 +ARG CHANNEL_URL=https://github.com/NixOS/nixpkgs/archive/1db42b7fe3878f3f5f7a4f2dc210772fd080e205.tar.gz + +ARG USER=vscode +ARG UID=1000 +ARG GID=${UID} +ARG NIX_INSTALLER=https://releases.nixos.org/nix/nix-${NIX_VERSION}/install + +SHELL [ "/bin/bash", "-o", "pipefail", "-o", "errexit", "-c" ] + +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && \ + apt-get install --yes --no-install-recommends \ + ca-certificates \ + curl \ + locales \ + make \ + acl \ + sudo \ + xz-utils + +RUN usermod --append --groups sudo ${USER} --shell /bin/bash && \ + usermod --append --groups root ${USER} --shell /bin/bash && \ + adduser ${USER} root && \ + sed --in-place 's/%sudo.*ALL/%sudo ALL=(ALL:ALL) NOPASSWD:ALL/' /etc/sudoers + +RUN mkdir --parents /etc/nix/ && \ + echo "sandbox = relaxed" >> /etc/nix/nix.conf && \ + echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf && \ + passwd --delete root + +USER ${USER} +ENV USER=${USER} + +ENV LOCALE_ARCHIVE=/usr/lib/locale/locale-archive +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US:en +ENV LC_ALL=en_US.UTF-8 + +# Generate en_US.UTF-8 locale +RUN locale-gen en_US.UTF-8 && \ + sudo dpkg-reconfigure --frontend=noninteractive locales && \ + sudo locale-gen en_US.UTF-8 + +RUN curl --location ${NIX_INSTALLER} > ~/install.sh && \ + chmod +x ~/install.sh && \ + ~/install.sh + +RUN source ~/.nix-profile/etc/profile.d/nix.sh && \ + nix-channel --add ${CHANNEL_URL} nixpkgs && \ + nix-channel --update + +RUN echo "source ~/.nix-profile/etc/profile.d/nix.sh" >> ~/.profile && \ + echo "source ~/.nix-profile/etc/profile.d/nix.sh" >> ~/.bashrc + +WORKDIR /home/${USER}/ + +COPY --chown=${USER}:${USER} . . + +RUN source ~/.nix-profile/etc/profile.d/nix.sh && \ + nix-env --set-flag priority 10 nix-${NIX_VERSION} && \ + export "ARCH_OS=$(uname -m)-$(uname -s | tr '[:upper:]' '[:lower:]')" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..0e319b98b47 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "ockam", + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, + "remoteEnv": { + "LANG": "en_US.UTF-8", + "LANGUAGE": "en_US:en", + "LC_ALL": "en_US.UTF-8" + }, + "features": { + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, + "ghcr.io/devcontainers/features/rust:1": {} + }, + "postStartCommand": "sudo chmod 1777 /tmp/ && sudo setfacl -k /tmp" +} \ No newline at end of file