Skip to content

Commit f8311e4

Browse files
committed
Updated devcontainer config so all npm dev dependencies are baked into the image itself
Also switched to the official node image as the base docker image + upgraded to java v21
1 parent 471462c commit f8311e4

File tree

3 files changed

+62
-16
lines changed

3 files changed

+62
-16
lines changed

.devcontainer/Dockerfile

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,44 @@
1-
FROM salesforce/cli:2.82.6-full
1+
FROM node:22.15.0-bookworm
2+
3+
# https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_env_variables.htm
4+
# ENV SF_CONTAINER_MODE=true
5+
ENV SF_DISABLE_AUTOUPDATE=true
6+
ENV SF_DISABLE_TELEMETRY=true
7+
ENV SF_LOG_LEVEL=debug
8+
ENV SF_SKIP_NEW_VERSION_CHECK=true
9+
10+
WORKDIR /workspaces/NebulaLogger
11+
12+
# Setup npm dependencies (including sf CLI)
13+
COPY package.json ./
14+
COPY package-lock.json ./
15+
RUN npm ci
16+
17+
# Now that the npm dependencies are installed locally via package.json, (re-)install some of them globally
18+
# so they can be easily used within the devcontainer/VS Code.
19+
RUN npm install -g @salesforce/cli@$(node -p "require('./package.json').devDependencies['@salesforce/cli']")
20+
RUN npm install -g prettier@$(node -p "require('./package.json').devDependencies['prettier']")
221

322
# Set up sf plugins
423
RUN mkdir $HOME/.config && mkdir $HOME/.config/sf \
5-
# && echo '[ "@jongpie/sfdx-bummer-plugin", "jamessimone/sf-trace-plugin", "sf-trace-plugin" ]' > $HOME/.config/sf/unsignedPluginAllowList.json \
6-
&& echo '[ "@jongpie/sfdx-bummer-plugin" ]' > $HOME/.config/sf/unsignedPluginAllowList.json \
7-
# TODO migrate all scripts (including in build.yml) to use
8-
# the new code-analyzer plugin / eliminate sfdx-scanner
9-
&& sf plugins install code-analyzer@ \
10-
# && sf plugins install @salesforce/sfdx-scanner \
24+
# TODO revisit sf-trace-plugin install weirdness with @jamessimone
25+
&& echo '[ "@jongpie/sfdx-bummer-plugin", "jamessimone/sf-trace-plugin", "sf-trace-plugin" ]' > $HOME/.config/sf/unsignedPluginAllowList.json \
26+
&& sf plugins install code-analyzer \
27+
&& sf plugins install community \
28+
&& sf plugins install custom-metadata \
1129
&& sf plugins install @jongpie/sfdx-bummer-plugin \
30+
# I am still not clear why this is needed, but echo y is still needed here.
31+
# Putting the plugin into the allow list (above) doesn't seem to work for some reason.
1232
&& echo y | sf plugins install jamessimone/sf-trace-plugin
1333

34+
# Set up Java
35+
RUN apt-get update && apt-get install -y curl zip unzip && \
36+
curl -s "https://get.sdkman.io" | bash && \
37+
bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install java 21-tem"
38+
39+
ENV JAVA_HOME=/root/.sdkman/candidates/java/current
40+
ENV PATH="$JAVA_HOME/bin:$PATH"
41+
1442
# Set up Oh My Bash
1543
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" \
1644
&& sed -i 's/OSH_THEME=.*/OSH_THEME="agnoster"/' ~/.bashrc
17-
18-
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
19-
ENV PATH=$JAVA_HOME/bin:$PATH

.devcontainer/devcontainer.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
{
22
"name": "Nebula Logger Dev Container",
3+
"context": "..",
34
"dockerFile": "Dockerfile",
45
"features": {},
56
"remoteUser": "root",
7+
"workspaceFolder": "/workspaces/NebulaLogger",
8+
"postCreateCommand": "chmod +x scripts/dev/devcontainer-post-start.sh",
9+
"postStartCommand": "./scripts/dev/devcontainer-post-start.sh",
610
"mounts": [
7-
"source=${localWorkspaceFolder}/.npm,target=/home/vscode/.npm,type=bind",
8-
"source=${localWorkspaceFolder}/.sf,target=/home/vscode/.sf,type=bind",
9-
"source=${localWorkspaceFolder}/.sfdx,target=/home/vscode/.sfdx,type=bind"
11+
"source=nebula-logger-dev-npm-cache,target=/root/.npm,type=volume",
12+
"source=nebula-logger-dev-sf,target=/root/.sf,type=volume",
13+
"source=nebula-logger-dev-sfdx,target=/root/.sfdx,type=volume"
1014
],
11-
"postCreateCommand": "npm ci",
1215
"customizations": {
1316
"vscode": {
1417
"settings": {
15-
"codeAnalyzer.enableV5": true,
18+
"codeAnalyzer.analyzeOnOpen.enabled": false,
19+
"codeAnalyzer.normalizeSeverity.enabled": false,
20+
"codeAnalyzer.scanner.engines": "pmd,retire-js,eslint-lwc",
1621
"editor.defaultFormatter": "esbenp.prettier-vscode",
1722
"editor.formatOnSave": true,
1823
"explorer.copyRelativePathSeparator": "/",
@@ -39,7 +44,7 @@
3944
"tags": false,
4045
"worktrees": false
4146
},
42-
"salesforcedx-vscode-apex.java.home": "/usr/lib/jvm/java-11-openjdk-amd64",
47+
"salesforcedx-vscode-apex.java.home": "/root/.sdkman/candidates/java/current",
4348
"salesforcedx-vscode-core.show-cli-success-msg": false,
4449
"terminal.integrated.defaultProfile.linux": "bash"
4550
},
@@ -54,6 +59,8 @@
5459
"github.vscode-github-actions",
5560
"github.vscode-pull-request-github",
5661
"gruntfuggly.todo-tree",
62+
"janisdd.vscode-edit-csv",
63+
"mechatroner.rainbow-csv",
5764
"mhutchie.git-graph",
5865
"modicatech.apex-code-coverage-visualizer",
5966
"ms-azuretools.vscode-docker",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if sf org display --json > /dev/null 2>&1; then
6+
echo "Default org found, running startup script..."
7+
sf apex trace
8+
wait
9+
10+
sf lightning debug
11+
wait
12+
else
13+
echo "No default org set — skipping script."
14+
fi

0 commit comments

Comments
 (0)