diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f2432aed..02d5fae2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,12 +1,19 @@ -FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye +FROM ubuntu:latest +RUN apt update -y +RUN apt install -y curl xz-utils git direnv && mkdir /nix +RUN \ + useradd -m -s /bin/bash -u 1000 dev;\ + chown dev /nix;\ + mkdir -p /etc/nix;\ + echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf +ENV USER=dev +USER dev +WORKDIR /home/dev +RUN curl -L https://nixos.org/nix/install | sh -s -- --no-daemon; +ENV PATH="/home/dev/.nix-profile/bin:${PATH}" -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - -# [Optional] Uncomment if you want to install an additional version of node using nvm -# ARG EXTRA_NODE_VERSION=10 -# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" - -# [Optional] Uncomment if you want to install more global node modules -# RUN su node -c "npm install -g " +ARG PNPM_STORE_DIR=/home/dev/.local/share/pnpm +ENV PNPM_STORE_DIR=${PNPM_STORE_DIR} +RUN mkdir -p "${PNPM_STORE_DIR}" +COPY --chown=dev:dev flake.lock flake.nix rust-toolchain.toml ./ +RUN nix develop --command bash -c "pnpm config set store-dir ${PNPM_STORE_DIR}" && rm flake.lock flake.nix rust-toolchain.toml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7b71f33a..47eb82a2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,10 +7,6 @@ "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", // Features to add to the dev container. More info: https://containers.dev/features. "features": { - "ghcr.io/devcontainers/features/nix:1": { - "extraNixConfig": "experimental-features = nix-command flakes repl-flake" - }, - "ghcr.io/christophermacgown/devcontainer-features/direnv:1": {} }, // Configure tool-specific properties. @@ -21,7 +17,8 @@ "bradlc.vscode-tailwindcss", "dprint.dprint", "rust-lang.rust-analyzer", - "mkhl.direnv" + "mkhl.direnv", + "dbaeumer.vscode-eslint" ] } }, @@ -30,7 +27,9 @@ // This can be used to network with other containers or with the host. "forwardPorts": [3000, 4841, 9000, 9090, 8080], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "cp .env.local.example .env.local && nix develop --command bash -c 'pnpm config set store-dir ~/pnpm-store' && direnv allow" - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + "postCreateCommand": "cp .env.local.example .env.local && direnv allow", + + // More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "dev", + "containerUser": "dev" } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index f0d5a66b..8f068347 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -3,11 +3,10 @@ version: '3.8' services: app: build: - context: . - dockerfile: Dockerfile + context: .. + dockerfile: .devcontainer/Dockerfile volumes: - - nix-store:/nix:cached - ../..:/workspaces:cached # Overrides default command so things don't shut down after the process ends.