Skip to content

Commit 474686c

Browse files
committed
Create custom devcontainer
1 parent 8e6d72d commit 474686c

6 files changed

Lines changed: 82 additions & 10 deletions

File tree

.devcontainer/Dockerfile

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