Skip to content

Commit b5bb497

Browse files
committed
Create custom devcontainer
1 parent 8e6d72d commit b5bb497

6 files changed

Lines changed: 85 additions & 10 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# syntax=docker/dockerfile:labs
2+
FROM mcr.microsoft.com/devcontainers/base:debian
3+
4+
RUN <<-SCRIPT
5+
set -o errexit
6+
set -o verbose
7+
8+
rm -Rf ~/.oh-my-zsh
9+
10+
apt update
11+
apt full-upgrade -qy
12+
apt install -qy \
13+
bash \
14+
curl \
15+
git \
16+
nano \
17+
protobuf-compiler \
18+
python3 \
19+
tmux \
20+
vim \
21+
zplug \
22+
zsh
23+
chsh -s "$(command -v zsh)"
24+
25+
# Set up ohmyzsh and change the shell to zsh
26+
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
27+
SCRIPT
28+
29+
SHELL ["/usr/bin/env", "zsh", "-c"]
30+
31+
# Configure sdkman.
32+
RUN <<-SCRIPT
33+
set -o errexit
34+
set -o verbose
35+
curl -s "https://get.sdkman.io" | bash
36+
37+
set +o errexit
38+
source /root/.sdkman/bin/sdkman-init.sh
39+
set -o errexit
40+
41+
# Install java tooling we need
42+
sdk install java
43+
sdk install maven
44+
sdk install mvnd
45+
SCRIPT

.devcontainer/devcontainer.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
2-
"image": "mcr.microsoft.com/devcontainers/java:dev-21",
3-
"features": {
4-
"ghcr.io/devcontainers/features/common-utils:2": {},
5-
"ghcr.io/devcontainers-contrib/features/protoc:1": {
6-
"version": "latest"
7-
}
2+
"build": {
3+
"dockerfile": "Dockerfile"
84
}
95
}

.github/workflows/devcontainer.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build Devcontainer
2+
on:
3+
pull_request:
4+
paths:
5+
- .devcontainer/**
6+
- .github/workflows/devcontainer.yml
7+
8+
workflow_call: {}
9+
workflow_dispatch: {}
10+
11+
jobs:
12+
build:
13+
name: Build Devcontainer
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Build Devcontainer
21+
run: |-
22+
set -o errexit
23+
set -o nounset
24+
set -o xtrace
25+
26+
# Verify docker is up first.
27+
docker run --rm hello-world
28+
29+
# Verify the devcontainer builds correctly.
30+
npm install -g @devcontainers/cli
31+
devcontainer build \
32+
--workspace-folder . \
33+
--push false \
34+
--image-name ghcr.io/ascopes/protobuf-maven-plugin/devcontainer:latest

scripts/bump-versions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
###
77
set -o errexit
88
set -o nounset
9-
[[ -n ${DEBUG+undef} ]] && set -o xtrace
9+
[[ -v DEBUG ]] && set -o xtrace
1010

1111
function usage() {
1212
echo "USAGE: ${BASH_SOURCE[0]} [ -h | -m | -M ]"

scripts/install-protoc-to-github-runner.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
###
99
set -o errexit
1010
set -o nounset
11-
[[ -n ${DEBUG+defined} ]] && set -o xtrace
11+
[[ -v DEBUG ]] && set -o xtrace
1212

1313
cd "$(dirname "${BASH_SOURCE[0]}")/.."
1414
echo "Checking protobuf version from pom.xml..."
@@ -52,7 +52,6 @@ readonly target=${target_dir}/protoc
5252
echo "${target_dir}" >> "${GITHUB_PATH}"
5353
export PATH="${PATH}:${target_dir}"
5454

55-
5655
echo "Downloading protoc ${version} for OS ${os_name} and CPU ${os_arch}"
5756
echo "Installing ${url} to ${target}"
5857

scripts/site-local.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
### Author: Ashley Scopes
66
###
77
set -o errexit
8+
set -o nounset
89
set -o pipefail
9-
[[ -n ${DEBUG+undef} ]] && set -o xtrace
10+
[[ -v DEBUG ]] && set -o xtrace
1011

1112
readonly host=127.0.0.1
1213
readonly port=9000

0 commit comments

Comments
 (0)