Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 5456fee

Browse files
authored
Merge pull request #126 from microsoft/clantz/alpine-3.10
Alpine 3.10 container
2 parents 4f962ab + 6e7deb3 commit 5456fee

File tree

4 files changed

+163
-0
lines changed

4 files changed

+163
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
FROM alpine:3.10
6+
7+
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
8+
# this user's GID/UID must match your local user UID/GID to avoid permission issues
9+
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
10+
# https://aka.ms/vscode-remote/containers/non-root-user for details.
11+
ARG USERNAME=vscode
12+
ARG USER_UID=1000
13+
ARG USER_GID=$USER_UID
14+
15+
# Install git, bash, dependencies, and add a non-root user
16+
RUN apk add --no-cache git bash libgcc libstdc++ \
17+
#
18+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
19+
&& addgroup -g $USER_GID $USERNAME \
20+
&& adduser -S -s /bin/bash -u $USER_UID -G $USERNAME $USERNAME \
21+
# [Optional] Add sudo support for the non-root user
22+
&& apk add --no-cache sudo \
23+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
24+
&& chmod 0440 /etc/sudoers.d/$USERNAME
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "Alpine 3.10",
3+
"dockerFile": "Dockerfile",
4+
5+
"runArgs": [
6+
// Uncomment the line if you will use a ptrace-based debugger like Go.
7+
// "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined",
8+
9+
// Uncomment the next line to use a non-root user. On Linux, this will prevent
10+
// new files getting created as root, but you may need to update the USER_UID
11+
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
12+
// "-u", "vscode"
13+
],
14+
15+
// Use 'settings' to set *default* container specific settings.json values on container create.
16+
// You can edit these settings after create using File > Preferences > Settings > Remote.
17+
"settings": {
18+
// This dev container does include /bin/bash if you prefer to use it instead of ash.
19+
"terminal.integrated.shell.linux": "/bin/ash"
20+
},
21+
22+
// Uncomment the next line if you want to publish any ports.
23+
// "appPort": [],
24+
25+
// Uncomment the next line to run commands after the container is created.
26+
// "postCreateCommand": "uname -a",
27+
28+
// Add the IDs of extensions you want installed when the container is created in the array
29+
// below. Note that some extensions may not work in Alpine Linux due to glibc dependencies
30+
// in native code inside the extension. See https://aka.ms/vscode-remote/linux for details.
31+
"extensions": []
32+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Alpine 3.10 & Git
2+
3+
## Summary
4+
5+
*Simple Alpine 3.10 container with Git installed.*
6+
7+
| Metadata | Value |
8+
|----------|-------|
9+
| *Contributors* | The VS Code Team |
10+
| *Definition type* | Dockerfile |
11+
| *Languages, platforms* | Any |
12+
13+
## Using this definition with an existing folder
14+
15+
This definition does not require any special steps to use.
16+
17+
However, note that some extensions may not work in Alpine Linux due to `glibc` dependencies in native code inside the extension. You should also be aware that 3rd party tools, runtimes, and SDKs may not include a version that works on Alpine Linux for the same reason.
18+
19+
See [Remote Development and Linux](https://aka.ms/vscode-remote/linux) for details.
20+
21+
Just follow these steps:
22+
23+
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
24+
25+
2. To use VS Code's copy of this definition:
26+
1. Start VS Code and open your project folder.
27+
2. Press <kbd>F1</kbd> select and **Remote-Containers: Add Development Container Configuration Files...** from the command palette.
28+
3. Select the Debian 9 & Git definition.
29+
30+
3. To use latest-and-greatest copy of this definition from the repository:
31+
1. Clone this repository.
32+
2. Copy the contents of `containers/alpine-3.10-git/.devcontainer` to the root of your project folder.
33+
3. Start VS Code and open your project folder.
34+
35+
4. After following step 2 or 3, the contents of the `.devcontainer` folder in your project can be adapted to meet your needs.
36+
37+
5. Finally, press <kbd>F1</kbd> and run **Remote-Containers: Reopen Folder in Container** to start using the definition.
38+
39+
## Testing the definition
40+
41+
This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:
42+
43+
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
44+
2. Clone this repository.
45+
3. Start VS Code, press <kbd>F1</kbd>, and select **Remote-Containers: Open Folder in Container...**
46+
4. Select the `containers/alpine-3.10-git` folder.
47+
5. Press <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>\`</kbd> and type the following command to verify installation: `git --version`
48+
6. You should see the Git version and details about the version of Linux in the container.
49+
50+
## License
51+
52+
Copyright (c) Microsoft Corporation. All rights reserved.
53+
54+
Licensed under the MIT License. See [LICENSE](https://github.com/Microsoft/vscode-dev-containers/blob/master/LICENSE)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
cd $(dirname "$0")
3+
4+
if [ -z $HOME ]; then
5+
HOME="/root"
6+
fi
7+
8+
FAILED=()
9+
10+
check() {
11+
LABEL=$1
12+
shift
13+
echo -e "\n🧪 Testing $LABEL: $@"
14+
if $@; then
15+
echo "🏆 Passed!"
16+
else
17+
echo "💥 $LABEL check failed."
18+
FAILED+=("$LABEL")
19+
fi
20+
}
21+
22+
checkMultiple() {
23+
PASSED=0
24+
LABEL="$1"
25+
shift; MINIMUMPASSED=$1
26+
shift; EXPRESSION="$1"
27+
while [ "$EXPRESSION" != "" ]; do
28+
if $EXPRESSION; then ((PASSED++)); fi
29+
shift; EXPRESSION=$1
30+
done
31+
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
32+
}
33+
34+
checkExtension() {
35+
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]"
36+
}
37+
38+
# Actual tests
39+
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]"
40+
check "non-root-user" "id vscode"
41+
check "/home/vscode" [ -d "/home/vscode" ]
42+
check "sudo" sudo -u vscode echo "sudo works."
43+
check "git" git --version
44+
check "command-line-tools" which top ip
45+
46+
# Report result
47+
if [ ${#FAILED[@]} -ne 0 ]; then
48+
echo -e "\n💥 Failed tests: ${FAILED[@]}"
49+
exit 1
50+
else
51+
echo -e "\n💯 All passed!"
52+
exit 0
53+
fi

0 commit comments

Comments
 (0)