Skip to content
Draft
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
34 changes: 34 additions & 0 deletions .devcontainer/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM mcr.microsoft.com/devcontainers/go:1-1.24-bookworm

ARG DEVCONTAINER_VERSION

LABEL org.opencontainers.image.ref.name="steampipe-postgres-fdw-devcontainer" \
org.opencontainers.image.version="${DEVCONTAINER_VERSION}" \
org.opencontainers.image.url="https://steampipe.io" \
org.opencontainers.image.authors="Turbot HQ, Inc" \
org.opencontainers.image.source="https://github.com/turbot/steampipe-postgres-fdw" \
org.opencontainers.image.description="Development container for Steampipe PostgreSQL FDW"

# Install PostgreSQL and development dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-15 \
postgresql-server-dev-15 \
libpq-dev \
build-essential \
gcc \
make \
rsync \
gettext \
&& echo 'vscode ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \
&& systemctl disable postgresql || true \
&& rm -rf /var/lib/apt/lists/*

# Switch to vscode user for Go package installs
USER vscode

# Install common Go tools for FDW development
RUN
# RUN go install golang.org/x/tools/gopls@latest \
# && go install github.com/go-delve/delve/cmd/dlv@latest \
# && go install honnef.co/go/tools/cmd/staticcheck@latest
20 changes: 20 additions & 0 deletions .devcontainer/build/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
VERSION ?= 1.0.0

build:
docker buildx build --push --platform linux/arm64,linux/amd64 \
--tag ghcr.io/turbot/steampipe-postgres-fdw-devcontainer:$(VERSION) \
--build-arg DEVCONTAINER_VERSION=$(VERSION) \
.

build-local:
docker build --tag steampipe-postgres-fdw-devcontainer:$(VERSION) \
--build-arg DEVCONTAINER_VERSION=$(VERSION) \
.

test: build-local
docker run --rm steampipe-postgres-fdw-devcontainer:$(VERSION) /bin/bash -c "\
echo 'Testing dev container:' && \
go version && \
pg_config --version && \
gcc --version | head -n1 && \
echo 'All tools available!'"
20 changes: 20 additions & 0 deletions .devcontainer/build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Steampipe PostgreSQL FDW Dev Container Build

This directory contains the build configuration for the Steampipe PostgreSQL FDW development container image.

## Building

```bash
# Build and push to registry (requires push permissions)
make build VERSION=1.0.0

# Build locally for testing
make build-local VERSION=1.0.0

# Test the built image
make test VERSION=1.0.0
```

## Publishing

The built image is published to `ghcr.io/turbot/steampipe-postgres-fdw-devcontainer:VERSION` and referenced in the main `devcontainer.json`.
45 changes: 45 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "Steampipe PostgreSQL FDW Dev Container (Local Build)",
"dockerFile": "build/Dockerfile",
"build": {
"args": {
"DEVCONTAINER_VERSION": "local"
}
},
"forwardPorts": [5432],
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": true,
"installOhMyZsh": true,
"upgradePackages": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},

"runArgs": [
"--privileged"
],

"customizations": {
"vscode": {
"extensions": [
"golang.go",
"ms-vscode.cpptools",
"ms-vscode.makefile-tools",
"redhat.vscode-yaml",
"ms-vscode.vscode-json"
],
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"terminal.integrated.defaultProfile.linux": "bash"
}
}
},

"postCreateCommand": "echo '🎉 Steampipe PostgreSQL FDW dev container ready!' && ./.devcontainer/setup-verification.sh"
}
107 changes: 107 additions & 0 deletions .devcontainer/setup-verification.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/bin/bash

# Steampipe PostgreSQL FDW Dev Container Setup Verification
# This script verifies that all required tools and dependencies are properly installed

echo "🔍 Steampipe PostgreSQL FDW Development Environment Verification"
echo "================================================================="

# Function to check if command exists
check_command() {
if command -v "$1" >/dev/null 2>&1; then
echo "✅ $1 is installed"
return 0
else
echo "❌ $1 is NOT installed"
return 1
fi
}

# Function to check version
check_version() {
local cmd="$1"
local version_cmd="$2"
echo "📋 $cmd version: $($version_cmd 2>/dev/null || echo 'Unable to determine version')"
}

echo ""
echo "🔧 Checking core development tools..."
check_command "go" && check_version "Go" "go version"
check_command "gcc" && check_version "GCC" "gcc --version | head -n1"
check_command "make" && check_version "Make" "make --version | head -n1"
check_command "pg_config" && check_version "PostgreSQL" "pg_config --version"

echo ""
echo "📦 Checking PostgreSQL development components..."
PG_INCLUDEDIR=$(pg_config --includedir 2>/dev/null)
PG_INCLUDEDIR_SERVER=$(pg_config --includedir-server 2>/dev/null)

if [ -d "$PG_INCLUDEDIR" ]; then
echo "✅ PostgreSQL include directory exists: $PG_INCLUDEDIR"
else
echo "❌ PostgreSQL include directory missing: $PG_INCLUDEDIR"
fi

if [ -d "$PG_INCLUDEDIR_SERVER" ]; then
echo "✅ PostgreSQL server include directory exists: $PG_INCLUDEDIR_SERVER"
else
echo "❌ PostgreSQL server include directory missing: $PG_INCLUDEDIR_SERVER"
fi

echo ""
echo "🏗️ Checking build environment..."
check_command "rsync"
check_command "gettext"
check_command "git"

echo ""
echo "🔍 Go environment check..."
echo "📋 GOPATH: ${GOPATH:-'Not set'}"
echo "📋 GOROOT: ${GOROOT:-'Not set'}"
echo "📋 PATH includes Go: $(echo $PATH | grep -q go && echo 'Yes' || echo 'No')"

# Check Go tools
# echo ""
# echo "🛠️ Checking Go development tools..."
# check_command "gopls"
# check_command "dlv"
# check_command "staticcheck"

echo ""
echo "📁 Checking workspace permissions..."
if [ -w "/workspace" ]; then
echo "✅ Workspace is writable"
else
echo "❌ Workspace is not writable"
fi

echo ""
echo "🧪 Testing basic build preparation..."
cd /workspace

# Test prebuild.go generation
if make prebuild.go >/dev/null 2>&1; then
echo "✅ prebuild.go generation works"
rm -f prebuild.go prebuild.go.bak
else
echo "❌ prebuild.go generation failed"
fi

echo ""
echo "📋 Environment Summary:"
echo " • Container user: $(whoami)"
echo " • Working directory: $(pwd)"
echo " • PostgreSQL version: $(pg_config --version 2>/dev/null | cut -d' ' -f2 || echo 'Unknown')"
echo " • Go version: $(go version 2>/dev/null | cut -d' ' -f3 || echo 'Unknown')"
echo " • Platform: $(uname -s)"

echo ""
echo "🚀 Ready to build! Try these commands:"
echo " make build # Build the generic FDW"
echo " make clean # Clean build artifacts"
echo " fdw-help # Show help information"
echo ""
echo "📚 For plugin-specific builds:"
echo " make standalone plugin=aws plugin_github_url=github.com/turbot/steampipe-plugin-aws"
echo ""
echo "================================================================="
Loading