Skip to content

Commit

Permalink
Add debian-based variant
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoscna committed Mar 15, 2021
1 parent af62022 commit 33c0f1e
Show file tree
Hide file tree
Showing 45 changed files with 375 additions and 15 deletions.
7 changes: 6 additions & 1 deletion .github/dependabot.yml
Expand Up @@ -7,6 +7,11 @@ updates:
interval: weekly

- package-ecosystem: docker
directory: /
directory: /alpine/
schedule:
interval: weekly

- package-ecosystem: docker
directory: /debian
schedule:
interval: weekly
6 changes: 6 additions & 0 deletions .github/workflows/anchore-analysis.yml
Expand Up @@ -14,6 +14,11 @@ on:
jobs:
anchore-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
variant:
- alpine
- debian
steps:
- name: Checkout source code
uses: actions/checkout@v2.3.4
Expand All @@ -22,6 +27,7 @@ jobs:
- name: Build the Docker image
uses: docker/build-push-action@v2.2.0
with:
context: ${{ matrix.variant }}
push: false
tags: ${{ env.DOCKER_IMAGE_NAME }}:latest
- name: Perform Anchore analysis
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/build-publish.yml
Expand Up @@ -11,6 +11,15 @@ on:
jobs:
build-publish:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- variant: alpine
tagLatest: alpine
tagSuffix: alpine
- variant: debian
tagLatest: latest
tagSuffix: ""
steps:
- name: Checkout source code
uses: actions/checkout@v2.3.4
Expand All @@ -23,9 +32,10 @@ jobs:
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Get release version
id: get_release_version
run: echo ::set-output name=tags::${GITHUB_REF#refs/*/v}
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/v}
- name: Build and Push the Docker image
uses: docker/build-push-action@v2.2.0
with:
context: ${{ matrix.variant }}
push: true
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.get_release_version.outputs.tags }},${{ env.DOCKER_IMAGE_NAME }}:latest
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.get_release_version.outputs.tag }}${{ matrix.tagSuffix }},${{ env.DOCKER_IMAGE_NAME }}:${{ matrix.tagLatest }}
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Expand Up @@ -11,6 +11,11 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
variant:
- alpine
- debian
steps:
- name: Checkout source code
uses: actions/checkout@v2.3.4
Expand All @@ -19,4 +24,5 @@ jobs:
- name: Build the Docker image
uses: docker/build-push-action@v2.2.0
with:
context: ${{ matrix.variant }}
push: false
6 changes: 6 additions & 0 deletions .github/workflows/dive-analysis.yml
Expand Up @@ -14,6 +14,11 @@ on:
jobs:
dive-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
variant:
- alpine
- debian
steps:
- name: Checkout source code
uses: actions/checkout@v2.3.4
Expand All @@ -22,6 +27,7 @@ jobs:
- name: Build the Docker image
uses: docker/build-push-action@v2.2.0
with:
context: ${{ matrix.variant }}
load: true
push: false
tags: ${{ env.DOCKER_IMAGE_NAME }}:latest
Expand Down
24 changes: 15 additions & 9 deletions README.md
@@ -1,29 +1,35 @@
# Visual Studio Code Development Container

`paniclobster/devcontainer-base` is an alpine-based image with a
configurable setup for different development workspaces needs.
`paniclobster/devcontainer-base` is a Docker image built upon both Alpine and
Debian with a configurable setup for different development workspaces needs.

[![build](https://github.com/paniclobster/devcontainer-base/workflows/build/badge.svg)](https://github.com/paniclobster/devcontainer-base/actions/)
[![license](https://img.shields.io/github/license/paniclobster/devcontainer-base)](https://github.com/paniclobster/devcontainer-base/blob/main/LICENSE.md)
[![docker hub](https://img.shields.io/docker/v/paniclobster/devcontainer-base?sort=semver)](https://hub.docker.com/r/paniclobster/devcontainer-base)
[![contributor covenant](https://img.shields.io/badge/contributor%20covenant-v2.0%20adopted-ff69b4.svg)](https://github.com/paniclobster/devcontainer-base/blob/main/CODE_OF_CONDUCT.md)

## Available Setups
## Alpine Available Setups

- Alpine SDK (alpine-sdk)
- Dapr CLI (dapr-cli)
- Ghostscript (ghostscript)
- Go (go, go-tools)
- Helm (helm)
- ImageMagick (imagemagick)
- Kubectl (kubernetes)
- Kustomize (kustomize)
- Minikube (minikube)
- Kubernetes (kubernetes, helm, kustomize, minikube, kind, skaffold)
- Node.js (node)
- Python 2 (python2)
- Python 3 (python3)

## Debian Available Setups

- Dapr CLI (dapr-cli)
- Ghostscript (ghostscript)
- Go (go, go-tools)
- ImageMagick (imagemagick)
- Kubernetes (kubernetes, helm, kustomize, minikube, kind, skaffold)
- Node.js (node)
- kind (kind)
- Python 2 (python2)
- Python 3 (python3)
- Skaffold (skaffold)

## Contributing

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup/setup-docker.sh → alpine/setup/setup-docker.sh
Expand Up @@ -16,7 +16,7 @@ DOCKER_HOST_SOCKET="/var/run/docker-host.sock"
DOCKER_SOCKET="/var/run/docker.sock"

sudo tee "${DEVCONTAINER_SETUP_DIR}/setup-docker-init.sh" >>/dev/null \
<<EOF
<<EOF
#!/usr/bin/env bash
set -e
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup/setup-python2.sh → alpine/setup/setup-python2.sh
Expand Up @@ -7,4 +7,4 @@ sudo apk add --no-cache \
python2

# Install pip
curl https://bootstrap.pypa.io/get-pip.py | sudo python2
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | sudo python2
2 changes: 1 addition & 1 deletion setup/setup-python3.sh → alpine/setup/setup-python3.sh
Expand Up @@ -7,7 +7,7 @@ sudo apk add --no-cache \
python3

# Install pip
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
curl https://bootstrap.pypa.io/get-pip.py | sudo python3

# Make symlinks that are expected to exist
sudo ln -s /usr/bin/pydoc3 /usr/bin/pydoc
Expand Down
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions debian/Dockerfile
@@ -0,0 +1,50 @@
# Base image
FROM debian:buster-slim

# Exit immediately if a command exits with a non-zero status
RUN set -e

# Install base dependencies
RUN apt-get update \
&& apt-get install --assume-yes \
curl \
git \
openssh-client \
nano \
sudo \
&& rm -rf /var/lib/apt/lists/*

# Create vscode user
ARG DEVCONTAINER_USERNAME=vscode
ENV DEVCONTAINER_USERNAME=$DEVCONTAINER_USERNAME
ARG GROUPNAME=$DEVCONTAINER_USERNAME
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd \
--gid $USER_GID \
$GROUPNAME \
&& useradd \
--create-home \
--home-dir /home/$DEVCONTAINER_USERNAME \
--gid $USER_GID \
--shell /bin/bash \
--uid $USER_UID \
$DEVCONTAINER_USERNAME \
&& echo $DEVCONTAINER_USERNAME ALL=\(root\) NOPASSWD:ALL >/etc/sudoers.d/$DEVCONTAINER_USERNAME \
&& chmod 0440 /etc/sudoers.d/$DEVCONTAINER_USERNAME

# Setup setup directory
ARG DEVCONTAINER_SETUP_DIR=/devcontainer/setup
ENV DEVCONTAINER_SETUP_DIR $DEVCONTAINER_SETUP_DIR
RUN mkdir -p \
$DEVCONTAINER_SETUP_DIR
COPY ./setup/*.sh $DEVCONTAINER_SETUP_DIR/
RUN chmod +x $DEVCONTAINER_SETUP_DIR/*.sh

# Add setup runner script
COPY ./scripts/devcontainer-setup.sh /usr/local/bin/devcontainer-setup
RUN chmod +x /usr/local/bin/devcontainer-setup

# Set user and workdir
USER $DEVCONTAINER_USERNAME
WORKDIR /home/$DEVCONTAINER_USERNAME
7 changes: 7 additions & 0 deletions debian/scripts/devcontainer-setup.sh
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e

if [ ! -f "${DEVCONTAINER_SETUP_DIR}/setup-${1}.log" ]; then
exec "${DEVCONTAINER_SETUP_DIR}/setup-${1}.sh" ${@:2} 2>&1 | sudo tee "${DEVCONTAINER_SETUP_DIR}/setup-${1}.log"
fi
7 changes: 7 additions & 0 deletions debian/setup/setup-dapr-cli.sh
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e

# Install Dapr CLI
DAPR_CLI_INSTALL_VERSION=${DAPR_CLI_VERSION:-master}
curl --location --silent "https://raw.githubusercontent.com/dapr/cli/${DAPR_CLI_INSTALL_VERSION}/install/install.sh" | sudo bash -
41 changes: 41 additions & 0 deletions debian/setup/setup-docker.sh
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -e

# Install docker
curl --location --silent "https://get.docker.com" | sudo bash -

# Install socat
sudo apt-get update \
&& sudo apt-get install --assume-yes \
procps \
socat \
&& sudo rm -rf /var/lib/apt/lists/*

# Grant docker access to user
sudo usermod --append --groups docker $DEVCONTAINER_USERNAME

# Configure docker socket
DOCKER_HOST_SOCKET="/var/run/docker-host.sock"
DOCKER_SOCKET="/var/run/docker.sock"

sudo tee "${DEVCONTAINER_SETUP_DIR}/setup-docker-init.sh" >>/dev/null \
<<EOF
#!/usr/bin/env bash
set -e
SOCAT_PATH_BASE=/tmp/vscr-dind-socat
SOCAT_LOG=\${SOCAT_PATH_BASE}.log
SOCAT_PID=\${SOCAT_PATH_BASE}.pid
if [ ! -f "\${SOCAT_PID}" ] || ! ps -p \$(cat \${SOCAT_PID}) > /dev/null; then
(sudo socat UNIX-LISTEN:${DOCKER_SOCKET},fork,mode=660,user=${DEVCONTAINER_USERNAME} UNIX-CONNECT:${DOCKER_HOST_SOCKET} 2>&1 | sudo tee -a \${SOCAT_LOG} > /dev/null & echo "\$!" | sudo tee \${SOCAT_PID} > /dev/null)
fi
EOF

sudo chmod +x "${DEVCONTAINER_SETUP_DIR}/setup-docker-init.sh"
sudo chown ${DEVCONTAINER_USERNAME}:root "${DEVCONTAINER_SETUP_DIR}/setup-docker-init.sh"

echo "${DEVCONTAINER_SETUP_DIR}/setup-docker-init.sh" | sudo tee -a /root/.bashrc >>/home/${DEVCONTAINER_USERNAME}/.bashrc
chown ${DEVCONTAINER_USERNAME} /home/${DEVCONTAINER_USERNAME}/.bashrc
9 changes: 9 additions & 0 deletions debian/setup/setup-ghostscript.sh
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

# Install Ghostscript
sudo apt-get update \
&& sudo apt-get install --assume-yes \
ghostscript \
&& sudo rm -rf /var/lib/apt/lists/*
29 changes: 29 additions & 0 deletions debian/setup/setup-go-tools.sh
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -e

# Install Go tools
export GOPATH=${DOCKER_GO_PATH}
go get -x -d github.com/stamblerre/gocode
go build -o gocode-gomod github.com/stamblerre/gocode
mv gocode-gomod "${GOPATH}/bin/"
go get -u -v \
github.com/acroca/go-symbols \
github.com/cweill/gotests/... \
github.com/davidrjenni/reftools/cmd/fillstruct \
github.com/fatih/gomodifytags \
github.com/go-delve/delve/cmd/dlv \
github.com/godoctor/godoctor \
github.com/haya14busa/goplay/cmd/goplay \
github.com/josharian/impl \
github.com/mdempsky/gocode \
github.com/ramya-rao-a/go-outline \
github.com/rogpeppe/godef \
github.com/sqs/goreturns \
github.com/stamblerre/gocode \
github.com/uudashr/gopkgs/v2/cmd/gopkgs \
github.com/uudashr/gopkgs/v2/cmd/gopkgs \
golang.org/x/lint/golint \
golang.org/x/tools/cmd/goimports \
golang.org/x/tools/cmd/gorename \
golang.org/x/tools/cmd/guru
16 changes: 16 additions & 0 deletions debian/setup/setup-go.sh
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -e

# Install go
sudo apt-get update \
&& sudo apt-get install --assume-yes \
golang
&& sudo rm -rf /var/lib/apt/lists/*

# Configure GOPATH
export GOPATH=${DOCKER_GO_PATH}
echo "export GOPATH=${GOPATH}" | tee -a /home/${DEVCONTAINER_USERNAME}/.bashrc >>/dev/null

sudo mkdir -p "${GOPATH}/bin" "${GOPATH}/src"
sudo chmod -R 777 "${GOPATH}"
7 changes: 7 additions & 0 deletions debian/setup/setup-helm.sh
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e

# Install Helm
HELM_INSTALL_VERSION=${HELM_VERSION:-master}
curl --location --silent "https://raw.githubusercontent.com/helm/helm/${HELM_INSTALL_VERSION}/scripts/get-helm-3" | sudo bash -
9 changes: 9 additions & 0 deletions debian/setup/setup-imagemagick.sh
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

# Install ImageMagick
sudo apt-get update \
&& sudo apt-get install --assume-yes \
imagemagick \
&& sudo rm -rf /var/lib/apt/lists/*
8 changes: 8 additions & 0 deletions debian/setup/setup-kind.sh
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -e

# Install kind
curl --silent "https://api.github.com/repos/kubernetes-sigs/kind/releases" | grep browser_download | grep linux | cut -d '"' -f 4 | grep amd64 | sort | tail -n 1 | xargs curl --location --output kind --silent
sudo install kind /usr/local/bin/
sudo rm ./kind

0 comments on commit 33c0f1e

Please sign in to comment.