Skip to content

Commit af44f79

Browse files
authored
Dev Container: Refresh 'docker-from-docker' and Chromium install (#5851)
Thanks, @tanviraumi !
1 parent 93b9b84 commit af44f79

File tree

2 files changed

+55
-48
lines changed

2 files changed

+55
-48
lines changed

.devcontainer/Dockerfile

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
# Fluid Development Container based on "docker-from-docker" template:
5+
# https://github.com/microsoft/vscode-dev-containers/blob/master/containers/docker-from-docker/.devcontainer/Dockerfile
6+
47
ARG NODE_VERSION=12
58

69
# 'node:${VARIANT}' base image includes the following:
@@ -9,41 +12,34 @@ ARG NODE_VERSION=12
912
#
1013
# Debian base image includes the following:
1114
#
12-
# curl, g++, git, make, procps, python, wget
15+
# ca-certificates, curl, g++, git, gnupg, libxss1, make, procps, python, wget
1316
#
1417
# (See https://github.com/microsoft/vscode-dev-containers/tree/master/containers/javascript-node/.devcontainer)
1518
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${NODE_VERSION}
1619

20+
# Install Chromium to get .so libraries required for Puppeteer tests.
21+
# (Note that Puppeteer bundles its own version of Chromium, we just need OS dependencies.)
22+
RUN export DEBIAN_FRONTEND=noninteractive \
23+
&& apt-get update \
24+
&& apt-get -y install --no-install-recommends chromium libxss1
25+
1726
# Install Docker CLI / Docker-Compose and create '/usr/local/share/docker-init.sh' to proxy the
1827
# docker socket. (We retrieve the script from the 'docker-from-docker' dev container template)
19-
RUN mkdir /tmp/library-scripts \
20-
&& curl -o /tmp/library-scripts/docker-debian.sh -sS https://raw.githubusercontent.com/microsoft/vscode-dev-containers/c3214ad7fcf5086e898e3941a36e0171959a48ca/containers/azure-ansible/.devcontainer/library-scripts/docker-debian.sh \
21-
&& /bin/bash /tmp/library-scripts/docker-debian.sh "${ENABLE_NONROOT_DOCKER}" "${SOURCE_SOCKET}" "${TARGET_SOCKET}" "node" \
22-
&& rm -rf /tmp/library-scripts/
2328

24-
# Update package information before installing
25-
RUN apt-get update
29+
# [Option] Enable non-root Docker access in container
30+
ARG ENABLE_NONROOT_DOCKER="true"
31+
# [Option] Use the OSS Moby CLI instead of the licensed Docker CLI
32+
ARG USE_MOBY="true"
2633

27-
# Install .so libraries required for Puppeteer tests
28-
RUN export DEBIAN_FRONTEND=noninteractive \
29-
&& apt-get -y install --no-install-recommends \
30-
libpangocairo-1.0-0 \
31-
libxi6 \
32-
libatk-bridge2.0-0 \
33-
libgtk-3-0 \
34-
libasound2 \
35-
libatk1.0-0 \
36-
libcups2 \
37-
libnss3 \
38-
libx11-6 \
39-
libx11-xcb1 \
40-
libxcomposite1 \
41-
libxcursor1 \
42-
libxdamage1 \
43-
libxext6 \
44-
libxrandr2 \
45-
libxss1 \
46-
libxtst6
34+
# A user of "automatic" attempts to reuse an user ID if one already exists.
35+
ARG USERNAME=automatic
36+
ARG USER_UID=1000
37+
ARG USER_GID=$USER_UID
38+
39+
RUN mkdir /tmp/library-scripts
40+
RUN wget -O /tmp/library-scripts/docker-debian.sh https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/containers/docker-from-docker/.devcontainer/library-scripts/docker-debian.sh
41+
RUN /bin/bash /tmp/library-scripts/docker-debian.sh "${ENABLE_NONROOT_DOCKER}" "/var/run/docker-host.sock" "/var/run/docker.sock" "${USERNAME}" "${USE_MOBY}"
42+
RUN rm -rf /tmp/library-scripts/
4743

4844
# Install additional desired packages here
4945
RUN export DEBIAN_FRONTEND=noninteractive \
@@ -63,3 +59,7 @@ RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:
6359

6460
# Copy our custom .zshrc to user's home directory
6561
COPY .zshrc /home/node/.zshrc
62+
63+
# Set '/usr/local/share/docker-init.sh' as entrypoint to proxy Docker socket on start.
64+
ENTRYPOINT ["/usr/local/share/docker-init.sh"]
65+
CMD ["sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
1+
// Fluid Development Container based on "docker-from-docker" template:
2+
// https://github.com/microsoft/vscode-dev-containers/blob/master/containers/docker-from-docker/.devcontainer/devcontainer.json
13
// For format details, see https://aka.ms/vscode-remote/devcontainer.json
24
{
3-
"name": "Fluid",
4-
"build": {
5-
"dockerfile": "Dockerfile",
5+
"name": "Fluid",
6+
"build": {
7+
"dockerfile": "Dockerfile",
8+
// Update 'NODE_VERSION' to pick a Node version: 10, 12, 14
9+
"args": {
10+
"NODE_VERSION": "12"
11+
}
12+
},
13+
"runArgs": [ "--init" ],
14+
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind" ],
15+
"overrideCommand": false,
616

7-
// Update 'NODE_VERSION' to pick a Node version: 10, 12, 14
8-
"args": { "NODE_VERSION": "12" }
9-
},
17+
// Set *default* container specific settings.json values on container create.
18+
"settings": {
19+
"terminal.integrated.shell.linux": "/usr/bin/zsh"
20+
},
1021

11-
// Invoke 'nvm' to install our preferred version of node, per the '.nvmrc' file
12-
// at the root of the ${workspaceFolder}.
13-
"postCreateCommand": ". /usr/local/share/nvm/nvm.sh; nvm install",
14-
15-
// Expose 'docker.sock' to the dev container and proxy access for the 'node' user.
16-
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind" ],
17-
"postStartCommand": "/usr/local/share/docker-init.sh",
18-
19-
// Set *default* container specific settings.json values on container create.
20-
"settings": { "terminal.integrated.shell.linux": "/usr/bin/zsh" },
21-
22-
// Add the IDs of extensions you want installed when the container is created.
23-
"extensions": [
22+
// Add the IDs of extensions you want installed when the container is created.
23+
"extensions": [
2424
"dbaeumer.vscode-eslint",
2525
"ms-azuretools.vscode-docker",
2626
"editorconfig.editorconfig"
27-
],
27+
],
2828

2929
// Forward port for Tinylicious
30-
"forwardPorts": [ 3000 ]
30+
"forwardPorts": [ 7070 ],
31+
32+
// Invoke 'nvm' to install our preferred version of node, per the '.nvmrc' file
33+
// located at the root of the ${workspaceFolder}.
34+
"postCreateCommand": ". /usr/local/share/nvm/nvm.sh; nvm install",
35+
36+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
37+
"remoteUser": "node"
3138
}

0 commit comments

Comments
 (0)