Created
November 1, 2020 19:05
-
-
Save PercyODI/33113286279a0545b7aeff5fafe9bfb5 to your computer and use it in GitHub Desktop.
VS Code Devcontainer Setup (Building code in C, including gdb, valgrind, and libcs50)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: | |
| // https://github.com/microsoft/vscode-dev-containers/tree/v0.128.0/containers/ubuntu | |
| { | |
| "name": "VUCS Assignments Workspace", | |
| "build": { | |
| "dockerfile": "Dockerfile", | |
| // Update 'VARIANT' to pick an Ubuntu version. Rebuild the container if it already | |
| // exists to update. Available variants: focal (or ubuntu-20.04), bionic (or ubuntu-18.04) | |
| "args": { "VARIANT": "focal" } | |
| }, | |
| // Set *default* container specific settings.json values on container create. | |
| "settings": { | |
| "terminal.integrated.shell.linux": "/bin/bash" | |
| }, | |
| // Add the IDs of extensions you want installed when the container is created. | |
| "extensions": ["ms-vscode.cpptools"] | |
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | |
| // "forwardPorts": [], | |
| // Use 'postCreateCommand' to run commands after the container is created. | |
| // "postCreateCommand": "uname -a", | |
| // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. | |
| // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], | |
| // Uncomment when using a ptrace-based debugger like C++, Go, and Rust | |
| // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], | |
| // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. | |
| // "remoteUser": "vscode" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #------------------------------------------------------------------------------------------------------------- | |
| # Copyright (c) Microsoft Corporation. All rights reserved. | |
| # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. | |
| #------------------------------------------------------------------------------------------------------------- | |
| # Update the VARIANT arg in devcontainer.json to pick an Ubuntu version: focal (or ubuntu-20.04), bionic (or ubuntu-18.04) | |
| # ARG VARIANT="focal" | |
| # FROM gcc:10.1 | |
| FROM ubuntu:bionic | |
| # This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" | |
| # property in devcontainer.json to use it. On Linux, the container user's GID/UIDs | |
| # will be updated to match your local UID/GID (when using the dockerFile property). | |
| # See https://aka.ms/vscode-remote/containers/non-root-user for details. | |
| ARG USERNAME=vscode | |
| ARG USER_UID=1000 | |
| ARG USER_GID=$USER_UID | |
| # Options for common package install script - SHA generated on release | |
| ARG INSTALL_ZSH="true" | |
| ARG UPGRADE_PACKAGES="true" | |
| ARG COMMON_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/v0.128.0/script-library/common-debian.sh" | |
| ARG COMMON_SCRIPT_SHA="a6bfacc5c9c6c3706adc8788bf70182729767955b7a5509598ac205ce6847e1e" | |
| # Configure apt and install packages | |
| RUN apt-get update \ | |
| && export DEBIAN_FRONTEND=noninteractive \ | |
| # | |
| # Verify git, common tools / libs installed, add/modify non-root user, optionally install zsh | |
| && apt-get -y install --no-install-recommends curl ca-certificates 2>&1 \ | |
| && curl -sSL ${COMMON_SCRIPT_SOURCE} -o /tmp/common-setup.sh \ | |
| && ([ "${COMMON_SCRIPT_SHA}" = "dev-mode" ] || (echo "${COMMON_SCRIPT_SHA} /tmp/common-setup.sh" | sha256sum -c -)) \ | |
| && /bin/bash /tmp/common-setup.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \ | |
| && rm /tmp/common-setup.sh | |
| # Install C tools | |
| RUN apt-get -y install build-essential gdb valgrind | |
| # Install CS50 Libraries | |
| RUN wget https://github.com/cs50/libcs50/archive/v10.1.0.zip \ | |
| && unzip v10.1.0.zip \ | |
| && cd libcs50-10.1.0 \ | |
| && make install | |
| # Clean ups | |
| RUN apt-get autoremove -y \ | |
| && apt-get clean -y \ | |
| && rm -rf /var/lib/apt/lists/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment