Skip to content

Commit 3c13d0f

Browse files
committed
Move to Go 1.15, add docker client
1 parent 4a91c69 commit 3c13d0f

File tree

6 files changed

+53
-6
lines changed

6 files changed

+53
-6
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
44
#-------------------------------------------------------------------------------------------------------------
55

6-
FROM golang:1.14-stretch
6+
FROM golang:1.15-stretch
77

88
# Avoid warnings by switching to noninteractive
99
ENV DEBIAN_FRONTEND=noninteractive
@@ -37,6 +37,8 @@ RUN groupadd --gid $USER_GID $USERNAME \
3737

3838
# Set default user
3939
USER $USERNAME
40+
RUN mkdir -p ~/.local/bin
41+
ENV PATH /home/${USERNAME}/.local/bin:$PATH
4042

4143
# Set env for tracking that we're running in a devcontainer
4244
ENV DEVCONTAINER=true
@@ -74,3 +76,9 @@ RUN /tmp/gh.sh
7476

7577
# symlink gh config folder
7678
RUN echo 'if [[ ! -d /home/vscode/.config/gh ]]; then mkdir -p /home/vscode/.config; ln -s /config/gh /home/vscode/.config/gh; fi ' >> ~/.bashrc
79+
80+
ARG DOCKER_GROUP_ID
81+
82+
# docker-from-docker
83+
COPY scripts/docker-client.sh /tmp/
84+
RUN /tmp/docker-client.sh

.devcontainer/devcontainer.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
"name": "devcontainer-cli",
55
"dockerFile": "Dockerfile",
66
"build": {
7-
"cacheFrom": "ghcr.io/stuartleeks/devcontainer-cli-devcontainer"
7+
"cacheFrom": "ghcr.io/stuartleeks/devcontainer-cli-devcontainer",
8+
"args": {
9+
// To ensure that the group ID for the docker group in the container
10+
// matches the group ID on the host, add this to your .bash_profile on the host
11+
// export DOCKER_GROUP_ID=$(getent group docker | awk -F ":" '{ print $3 }')
12+
"DOCKER_GROUP_ID": "${localEnv:DOCKER_GROUP_ID}"
13+
}
814
},
915
"runArgs": [
1016
// Uncomment the next line to use a non-root user. On Linux, this will prevent
@@ -49,7 +55,8 @@
4955
"darkriszty.markdown-table-prettify",
5056
"davidanson.vscode-markdownlint",
5157
"mushan.vscode-paste-image"
52-
],
58+
,
59+
"ms-azuretools.vscode-docker",],
5360

5461
// Use 'forwardPorts' to make a list of ports inside the container available locally.
5562
// "forwardPorts": [],
@@ -69,6 +76,6 @@
6976
// Mounts the .azure host folder into the dev container to pick up host az CLI login details
7077
"type=bind,source=${env:HOME}${env:USERPROFILE}/.azure,target=/home/vscode/.azure",
7178
// Mount host docker socket
72-
"type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock",
79+
"type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock",
7380
],
7481
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -e
3+
4+
VERSION=${1:-"20.10.5"}
5+
INSTALL_DIR=${2:-"$HOME/.local/bin"}
6+
CMD=docker
7+
NAME="Docker Client"
8+
9+
echo -e "\e[34m»»» 📦 \e[32mInstalling \e[33m$NAME \e[35mv$VERSION\e[0m ..."
10+
11+
mkdir -p $INSTALL_DIR
12+
curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-$VERSION.tgz -o /tmp/docker.tgz
13+
tar -zxvf /tmp/docker.tgz -C /tmp docker/docker
14+
chmod +x /tmp/docker/docker
15+
mv /tmp/docker/docker $INSTALL_DIR/docker
16+
rmdir /tmp/docker/
17+
rm -rf /tmp/docker.tgz
18+
19+
echo -e "\n\e[34m»»» 💾 \e[32mInstalled to: \e[33m$(which $CMD)"
20+
echo -e "\e[34m»»» 💡 \e[32mVersion details: \e[39m$($CMD --version)"
21+
22+
23+
if [ -z "$DOCKER_GROUP_ID" ]; then
24+
sudo groupadd docker
25+
else
26+
sudo groupadd -g $DOCKER_GROUP_ID docker
27+
fi
28+
29+
sudo usermod -aG docker $(whoami) && newgrp docker
30+
getent group docker

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"mode": "auto",
1212
"program": "${workspaceFolder}/cmd/devcontainer",
1313
"env": {},
14-
"args": ["template", "list"],
14+
"args": ["list"],
1515
"dlvLoadConfig": {
1616
"followPointers": true,
1717
"maxVariableRecurse": 1,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/spf13/cobra v1.0.0
1212
github.com/spf13/viper v1.4.0
1313
github.com/stretchr/testify v1.7.0
14-
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
14+
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 // indirect
1515
gopkg.in/yaml.v2 v2.4.0 // indirect
1616
)
1717

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK
183183
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
184184
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c h1:taxlMj0D/1sOAuv/CbSD+MMDof2vbyPTqz5FNYKpXt8=
185185
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
186+
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 h1:KzbpndAYEM+4oHRp9JmB2ewj0NHHxO3Z0g7Gus2O1kk=
187+
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
186188
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
187189
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
188190
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

0 commit comments

Comments
 (0)