Skip to content

Commit

Permalink
feat: custom docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
uonr committed Dec 25, 2023
1 parent 28f59f0 commit 8129b4a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
29 changes: 18 additions & 11 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <your-package-list-here>

# [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 <your-package-list-here>"
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
15 changes: 7 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -21,7 +17,8 @@
"bradlc.vscode-tailwindcss",
"dprint.dprint",
"rust-lang.rust-analyzer",
"mkhl.direnv"
"mkhl.direnv",
"dbaeumer.vscode-eslint"
]
}
},
Expand All @@ -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"
}
5 changes: 2 additions & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8129b4a

Please sign in to comment.