Skip to content

Commit 42b615a

Browse files
committed
chore: improvements for docker
1 parent de26501 commit 42b615a

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

apps/site/components/Downloads/Release/ReleaseCodeBox.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import { INSTALLATION_METHODS } from '@/util/downloadUtils';
1717
import LinkWithArrow from './LinkWithArrow';
1818

1919
// Creates a minimal JavaScript interpreter for parsing the JavaScript code from the snippets
20+
// Note: that the code runs inside a sandboxed environment and cannot interact with any code outside of the sandbox
21+
// It also does not have access to any Global or Window objects, nor it can execute code on the end-user's browser
22+
// It also only allows a return statement for a string and it forces the return value to also be a string and only be used
23+
// by Shiki to render the highlighted syntax. Hence XSS attacks or JavaScript injections are not possible.
2024
const interpreter = createSval({}, 'script');
2125

2226
const parseSnippet = (s: string, releaseContext: ReleaseContextType) => {
@@ -27,7 +31,7 @@ const parseSnippet = (s: string, releaseContext: ReleaseContextType) => {
2731
interpreter.run(`exports.content = \`${s}\``);
2832

2933
// Sets the parsed raw string to be used by the JSX CodeBox
30-
return interpreter.exports.content;
34+
return String(interpreter.exports.content);
3135
};
3236

3337
const ReleaseCodeBox: FC = () => {
@@ -54,7 +58,7 @@ const ReleaseCodeBox: FC = () => {
5458

5559
return parseSnippet(
5660
// Bundles the Platform and Package Manager snippets
57-
`${platformSnippet?.content ?? ''}${packageManagerSnippet?.content ?? ''}`,
61+
`${platformSnippet?.content ?? ''}\n${packageManagerSnippet?.content ?? ''}`,
5862
// Passes a partial state of only the things we need to the parser
5963
{ release, platform, os } as ReleaseContextType
6064
);

apps/site/snippets/en/download/docker.bash

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
# Pull the Node.js Docker image:
66
docker pull node:${props.release.major}-${props.release.major >= 4 ? 'alpine' : 'slim'}
77

8+
# Create a Node.js container and start a Shell session:
9+
docker run -it --rm --entrypoint sh node:${props.release.major}-${props.release.major >= 4 ? 'alpine' : 'slim'}
10+
811
# Verify the Node.js version:
9-
docker run node:${props.release.major}-${props.release.major >= 4 ? 'alpine' : 'slim'} node -v # Should print "${props.release.versionWithPrefix}".
12+
node -v # Should print "${props.release.versionWithPrefix}".
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
21
# Verify the Node.js version:
3-
${props.platform === 'DOCKER' ?
4-
`docker run node:${props.release.major}-${props.release.major >= 4 ? 'alpine' : 'slim'} npm -v # Should print "${props.release.npm}".` :
5-
`npm -v # Should print "${props.release.npm}".`
6-
}
2+
npm -v # Should print "${props.release.npm}".
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
21
# Download and install "pnpm":
32
${props.os === 'WIN' ?
43
'corepack enable pnpm' :
54
'curl -fsSL https://get.pnpm.io/install.sh | sh -'
65
}
76

87
# Verify "pnpm" version:
9-
${props.platform === 'DOCKER' ?
10-
`docker run node:${props.release.major}-${props.release.major >= 4 ? 'alpine' : 'slim'} pnpm -v` :
11-
'pnpm -v'
12-
}
8+
pnpm -v
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
21
# Download and install "Yarn":
32
corepack enable yarn
43

54
# Verify "Yarn" version:
6-
${props.platform === 'DOCKER' ?
7-
`docker run node:${props.release.major}-${props.release.major >= 4 ? 'alpine' : 'slim'} yarn -v` :
8-
'yarn -v'
9-
}
5+
yarn -v

0 commit comments

Comments
 (0)