Skip to content

Add experimental devcontainer #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM docker.io/library/debian

VOLUME /nix

RUN apt-get update
RUN apt-get -y install \
sudo \
xz-utils \
curl \
git \
direnv

ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
ENV DIRENV_CONFIG=/etc

# install bash config
COPY bash.bashrc /etc/bash.bashrc

# set env for non interactive shell to load nix
COPY envrc /etc/envrc
ENV ENV="/etc/envrc" BASH_ENV="/etc/envrc"

COPY ./nix.conf /etc/nix/nix.conf
COPY direnv.toml /etc

RUN --mount=type=secret,id=NIX_NETRC cp /run/secrets/NIX_NETRC /netrc && chmod a+r /netrc

# create non-root user and group and add it sudoers
ARG USERNAME=code
ARG USER_UID=1000
ARG USER_GID=${USER_UID}
RUN groupadd --gid ${USER_GID} ${USERNAME} && \
useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} -s /bin/bash && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/devcontainer && \
chmod 0440 /etc/sudoers.d/devcontainer

ARG NIX_INSTALL_SCRIPT=https://nixos.org/nix/install
RUN curl -L ${NIX_INSTALL_SCRIPT} | sudo -u code NIX_INSTALLER_NO_MODIFY_PROFILE=1 sh
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dockerComposeFile": "docker-compose.yaml",
"service": "mlabs-devcontainer",
"shutdownAction": "stopCompose",
"workspaceFolder": "/workspace",
"remoteUser": "code"
}
16 changes: 16 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
mlabs-devcontainer:
image: ghcr.io/mlabs-haskell/mlabs-devcontainer
platform: linux/x86_64
volumes:
- nix-store:/nix
- ..:/workspace:cached
command: /bin/sh -c "while sleep 1000; do :; done"
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined

volumes:
nix-store:
external: true