Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{
"name": "bucketeer",
"image": "ghcr.io/bucketeer-io/bucketeer-devcontainer:latest",
"privileged": true,
"capAdd": [
"SYS_ADMIN"
],
"securityOpt": [
"seccomp:unconfined"
],
"init": true,
"runArgs": [
"--cgroupns=host"
],
"mounts": [
// Persistent Go modules cache
"source=bucketeer-go-mod-cache,target=/go/pkg/mod,type=volume",
Expand Down
59 changes: 48 additions & 11 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,32 @@ export GOBIN="/home/codespace/go-tools/bin"
fix_cache_permissions() {
print_status "Ensuring cache directories have correct permissions..."

# Check if codespace user exists
if id "codespace" &>/dev/null; then
USER_NAME="codespace"
else
USER_NAME=$(whoami)
print_status "codespace user not found, using current user: $USER_NAME"
fi

# Fix Go modules cache permissions
sudo mkdir -p /go/pkg/mod /go/pkg/sumdb
sudo chown -R codespace:codespace /go/pkg/mod /go/pkg/sumdb
sudo chown -R $USER_NAME:$USER_NAME /go/pkg/mod /go/pkg/sumdb

# Fix Go tools directory permissions
if [ -d "/home/codespace/go-tools" ]; then
sudo chown -R codespace:codespace /home/codespace/go-tools
if [ -d "/home/$USER_NAME/go-tools" ]; then
sudo chown -R $USER_NAME:$USER_NAME /home/$USER_NAME/go-tools
fi

# Fix Yarn cache permissions
if [ -d "/home/codespace/.yarn" ]; then
sudo chown -R codespace:codespace /home/codespace/.yarn
if [ -d "/home/$USER_NAME/.yarn" ]; then
sudo chown -R $USER_NAME:$USER_NAME /home/$USER_NAME/.yarn
fi

# Fix node_modules permissions
for project in "${NODE_PROJECTS[@]}"; do
if [ -d "$project/node_modules" ]; then
sudo chown -R codespace:codespace "$project/node_modules"
sudo chown -R $USER_NAME:$USER_NAME "$project/node_modules"
fi
done

Expand Down Expand Up @@ -139,11 +147,18 @@ check_go_tools() {
install_go_tools() {
print_status "Installing Go development tools..."

# Check if codespace user exists
if id "codespace" &>/dev/null; then
USER_NAME="codespace"
else
USER_NAME=$(whoami)
fi

# Ensure go-tools directory exists and has correct permissions
sudo mkdir -p /home/codespace/go-tools/bin
sudo chown -R codespace:codespace /home/codespace/go-tools
sudo mkdir -p /home/$USER_NAME/go-tools/bin
sudo chown -R $USER_NAME:$USER_NAME /home/$USER_NAME/go-tools

cd /home/codespace/go-tools
cd /home/$USER_NAME/go-tools
if [ ! -e go.mod ]; then go mod init go-tools; fi

# Set additional Go environment variables for better module handling
Expand Down Expand Up @@ -237,9 +252,16 @@ install_node_deps() {

print_status "Installing $name dependencies..."

# Check if codespace user exists
if id "codespace" &>/dev/null; then
USER_NAME="codespace"
else
USER_NAME=$(whoami)
fi

# Ensure node_modules directory has correct permissions if it exists
if [ -d "$dir/node_modules" ]; then
sudo chown -R codespace:codespace "$dir/node_modules"
sudo chown -R $USER_NAME:$USER_NAME "$dir/node_modules"
fi

cd "$dir"
Expand Down Expand Up @@ -340,4 +362,19 @@ main() {
}

# Run main function
main "$@"
main "$@"

# Start Docker daemon automatically after main setup is complete
if ! docker info > /dev/null 2>&1; then
echo "🐳 Starting Docker daemon..."
nohup sudo dockerd > /tmp/dockerd.log 2>&1 < /dev/null &
# Wait for Docker to be ready
while ! docker info > /dev/null 2>&1; do
sleep 1
done
echo "✅ Docker daemon started successfully"
# Reset cursor position for clean terminal state
printf "\r"
else
echo "✅ Docker daemon already running"
fi
204 changes: 154 additions & 50 deletions .github/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,191 @@ FROM ubuntu:jammy

COPY first-run-notice.txt /tmp/scripts/

ENV LANG="C.UTF-8" \
DEBIAN_FRONTEND=noninteractive \
SHELL=/bin/bash \
DOCKER_BUILDKIT=1

# Restore man command
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# Restore man command
&& yes | unminimize 2>&1

ENV LANG="C.UTF-8"

# Install basic build tools
# Install packages in optimized order for better layer caching
RUN apt-get update \
&& apt-get upgrade -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
&& apt-get install -y --no-install-recommends \
# Core essentials (changes rarely)
ca-certificates \
curl \
gettext \
software-properties-common \
# Build tools (changes rarely)
make \
unzip \
# The tools in this package are used when installing packages for Python
build-essential \
swig3.0 \
# Required for Microsoft SQL Server
unixodbc-dev \
# Required for PostgreSQL
libpq-dev \
# Required for mysqlclient
default-libmysqlclient-dev \
# Required for ts
moreutils \
rsync \
cmake \
# File utilities
unzip \
zip \
libgdiplus \
rsync \
moreutils \
&& add-apt-repository universe \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install development packages in separate layer
RUN apt-get update && apt-get install -y --no-install-recommends \
# Development tools
jq \
vim \
vim-doc \
xtail \
sudo \
python3-pip \
#.NET Core related pre-requisites
python3-dev \
# Build and debug tools
swig3.0 \
cppcheck \
valgrind \
clang \
clang-format \
lldb \
llvm \
gdb \
# Database drivers
libpq-dev \
default-libmysqlclient-dev \
sqlite3 \
libsqlite3-dev \
unixodbc-dev \
# System libraries
libssl-dev \
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libncurses6 \
liblttng-ust1 \
libssl-dev \
libstdc++6 \
zlib1g \
libuuid1 \
libunwind8 \
sqlite3 \
libsqlite3-dev \
software-properties-common \
tk-dev \
uuid-dev \
curl \
gettext \
libgdiplus \
libsecret-1-dev \
# GUI libraries (useful for 'puppeteer' project)
libnss3 \
libnspr4 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libx11-6 \
libpangocairo-1.0-0 \
libx11-xcb1 \
libcups2 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libpango-1.0-0 \
libgbm1 \
libgtk-3-0 \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
# This is the folder containing 'links' to benv and build script generator
# Move first run notice to right spot
&& mkdir -p "/usr/local/etc/vscode-dev-containers/" \
&& mv -f /tmp/scripts/first-run-notice.txt /usr/local/etc/vscode-dev-containers/ \
&& rm -rf /tmp/scripts

# Install Go
RUN ARCH=$(dpkg --print-architecture) \
&& curl -fsSL "https://golang.org/dl/go1.24.1.linux-${ARCH}.tar.gz" | tar -C /usr/local -xzf -

# Install Node.js
RUN ARCH=$(dpkg --print-architecture) \
&& case $ARCH in \
amd64) NODE_ARCH="x64" ;; \
arm64) NODE_ARCH="arm64" ;; \
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
esac \
&& curl -fsSL "https://nodejs.org/dist/v22.18.0/node-v22.18.0-linux-${NODE_ARCH}.tar.xz" | tar -C /usr/local --strip-components=1 -xJ \
&& npm install -g yarn

# Install kubectl, helm, and minikube
RUN ARCH=$(dpkg --print-architecture) \
&& case $ARCH in \
amd64) K8S_ARCH="amd64" ;; \
arm64) K8S_ARCH="arm64" ;; \
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
esac \
# Install kubectl
&& curl -fsSL "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${K8S_ARCH}/kubectl" -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl \
# Install helm
&& curl -fsSL "https://get.helm.sh/helm-v3.16.4-linux-${K8S_ARCH}.tar.gz" | tar -C /tmp -xzf - \
&& mv "/tmp/linux-${K8S_ARCH}/helm" /usr/local/bin/helm \
&& rm -rf "/tmp/linux-${K8S_ARCH}" \
# Install minikube
&& curl -fsSL "https://storage.googleapis.com/minikube/releases/latest/minikube-linux-${K8S_ARCH}" -o /usr/local/bin/minikube \
&& chmod +x /usr/local/bin/minikube

# Set up Go environment
ENV PATH="/usr/local/go/bin:$PATH"
ENV GOPATH="/go"
ENV CGO_ENABLED=1

# Create go workspace
RUN mkdir -p /go/bin /go/src /go/pkg

# Create codespace user (matching what devcontainer features would create)
RUN groupadd --gid 1000 codespace \
&& useradd --uid 1000 --gid 1000 -m codespace \
&& echo "codespace ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/codespace \
&& chmod 0440 /etc/sudoers.d/codespace

# Install additional development tools
RUN ARCH=$(dpkg --print-architecture) \
# Install GitHub CLI
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=${ARCH} signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt-get update \
&& apt-get upgrade -y \
&& add-apt-repository universe \
&& apt-get install -y gh git-lfs \
# Install protoc
&& case $ARCH in \
amd64) PROTOC_ARCH="x86_64" ;; \
arm64) PROTOC_ARCH="aarch_64" ;; \
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
esac \
&& curl -fsSL "https://github.com/protocolbuffers/protobuf/releases/download/v23.4/protoc-23.4-linux-${PROTOC_ARCH}.zip" -o /tmp/protoc.zip \
&& unzip /tmp/protoc.zip -d /usr/local \
&& rm /tmp/protoc.zip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Verify expected build and debug tools are present
RUN apt-get update \
&& apt-get -y install build-essential cmake cppcheck valgrind clang clang-format lldb llvm gdb python3-dev \
# Install tools and shells not in common script
&& apt-get install -yq vim vim-doc xtail software-properties-common libsecret-1-dev \
# Install additional tools (useful for 'puppeteer' project)
&& apt-get install -y --no-install-recommends libnss3 libnspr4 libatk-bridge2.0-0 libatk1.0-0 libx11-6 libpangocairo-1.0-0 \
libx11-xcb1 libcups2 libxcomposite1 libxdamage1 libxfixes3 libpango-1.0-0 libgbm1 libgtk-3-0 \
# Clean up
&& apt-get autoremove -y && apt-get clean -y \
# Move first run notice to right spot
&& mkdir -p "/usr/local/etc/vscode-dev-containers/" \
&& mv -f /tmp/scripts/first-run-notice.txt /usr/local/etc/vscode-dev-containers/
# Install Docker for minikube
RUN curl -fsSL https://get.docker.com | sh \
&& usermod -aG docker codespace

# Default to bash shell (other shells available at /usr/bin/fish and /usr/bin/zsh)
ENV SHELL=/bin/bash \
DOCKER_BUILDKIT=1
# Create docker startup script
RUN echo '#!/bin/bash\n\
# Start docker daemon in background\n\
sudo dockerd > /dev/null 2>&1 &\n\
# Wait for docker to be ready\n\
while ! docker info > /dev/null 2>&1; do sleep 1; done\n\
# Execute the command\n\
exec "$@"' > /usr/local/bin/docker-init.sh \
&& chmod +x /usr/local/bin/docker-init.sh

# Remove scripts now that we're done with them
RUN apt-get clean -y && rm -rf /tmp/scripts
# Install Atlas for MySQL migration
RUN curl -sSf https://atlasgo.sh | sh -s -- -y

# Switch to codespace user
USER codespace

# Mount for docker-in-docker
VOLUME [ "/var/lib/docker" ]

# Fire Docker/Moby script if needed
ENTRYPOINT [ "/usr/local/share/docker-init.sh", "/usr/local/share/ssh-init.sh"]
# Fire Docker init script
ENTRYPOINT [ "/usr/local/bin/docker-init.sh" ]
CMD [ "sleep", "infinity" ]

# [Optional] Install debugger for development of Codespaces - Not in resulting image by default
Expand All @@ -90,5 +196,3 @@ RUN if [ -z $DeveloperBuild ]; then \
else \
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg ; \
fi
# Install the Atlas for MySQL migration
RUN curl -sSf https://atlasgo.sh | sh -s -- -y
Loading