Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
61 changes: 61 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Nessie Development Container
# Based on the project's requirements and existing Docker setup

FROM openjdk:21-jdk-slim

LABEL org.opencontainers.image.source=https://github.com/pirate-baby/nessie
LABEL org.opencontainers.image.description="Nessie Development Container"
LABEL org.opencontainers.image.licenses=Apache-2.0

# Set environment variables
ENV LANGUAGE='en_US:en'
ENV JAVA_HOME=/usr/local/openjdk-21
ENV PATH="${JAVA_HOME}/bin:${PATH}"

# Install development tools and dependencies
USER root

# Update packages and install development essentials
RUN apt-get update && \
apt-get install -y \
git \
curl \
wget \
findutils \
tar \
gzip \
unzip \
procps \
sudo \
&& rm -rf /var/lib/apt/lists/*

# Install Docker CLI (for potential Docker-in-Docker scenarios)
RUN curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz | \
tar -xz -C /tmp && \
mv /tmp/docker/docker /usr/local/bin/ && \
rm -rf /tmp/docker

# Create nessie user for development (matching project's pattern)
RUN groupadd --gid 10001 nessie && \
useradd --uid 10000 --gid nessie --create-home --shell /bin/bash nessie && \
usermod -aG sudo nessie && \
echo "nessie ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Set up workspace directory
RUN mkdir -p /workspace && \
chown -R nessie:nessie /workspace

# Switch to nessie user
USER nessie
WORKDIR /workspace

# Set user environment
ENV USER=nessie
ENV UID=10000
ENV HOME=/home/nessie

# Verify Java installation
RUN java --version && javac --version

# Set the default command
CMD ["/bin/bash"]
91 changes: 91 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Nessie Development Container

This directory contains a development container configuration for Project Nessie that provides a consistent, containerized development environment with all necessary tools pre-installed.

## What's Included

- **Java 21 JDK** - Full OpenJDK development environment
- **Gradle** - Build tool (downloaded automatically via wrapper)
- **Git** - Version control
- **Docker CLI** - For container operations
- **Development tools** - curl, wget, unzip, and other essentials
- **VS Code extensions** - Java development pack, Gradle support
- **User setup** - Non-root `nessie` user with sudo access

## Quick Start

### Option 1: VS Code Dev Containers (Recommended)

1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
2. Open the project in VS Code
3. When prompted, click "Reopen in Container" or use `Ctrl+Shift+P` → "Dev Containers: Reopen in Container"
4. Wait for the container to build and start

### Option 2: Manual Docker Usage

```bash
# Build the development container
docker build -f .devcontainer/Dockerfile -t nessie-dev .

# Run a shell in the container
docker run -it --rm -v $(pwd):/workspace -w /workspace nessie-dev bash

# Test the setup
./gradlew --version
java --version
```

## Development Workflow

Once in the container, you can use all the standard Nessie development commands:

```bash
# Basic smoke test
./gradlew sAp compileAll jar codeChecks

# Run tests
./gradlew test

# Run integration tests
./gradlew intTest

# Build and run the server
./gradlew :nessie-quarkus:quarkusBuild
java -jar servers/quarkus-server/build/quarkus-app/quarkus-run.jar
```

The Nessie server will be available at http://localhost:19120 (automatically forwarded in VS Code).

## Why Use This Dev Container?

This addresses the common issues mentioned in Nessie's contributing docs:

- ✅ **No "development on the metal"** - Everything runs in a safe, isolated container
- ✅ **Linux-first environment** - Even on macOS/Windows, you get a consistent Linux environment
- ✅ **No Podman conflicts** - Uses Docker with a standard Debian base
- ✅ **Pre-configured toolchain** - Java 21, Gradle, and all dependencies ready to go
- ✅ **VS Code integration** - Full IDE support with proper Java language server setup

## Container Details

- **Base Image**: `openjdk:21-jdk-slim` (Debian-based)
- **User**: `nessie` (UID 10000, GID 10001)
- **Working Directory**: `/workspace`
- **Port Forwarding**: 19120 (Nessie server)
- **Java Home**: `/usr/local/openjdk-21`

## Customization

You can modify the configuration by editing:
- `.devcontainer/devcontainer.json` - VS Code settings, extensions, port forwarding
- `.devcontainer/Dockerfile` - Container image, installed packages, environment

## Troubleshooting

**Container won't start**: Ensure Docker is running and you have sufficient disk space.

**Gradle issues**: The container automatically downloads Gradle via the wrapper. Make sure you have network access.

**Permission errors**: The container runs as user `nessie` with sudo access. Files should be automatically owned correctly.

**VS Code Java issues**: The container includes proper Java language server configuration. Reload VS Code if needed.
50 changes: 50 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "Nessie Development",
"build": {
"dockerfile": "Dockerfile",
"context": "."
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"vscjava.vscode-java-pack",
"redhat.java",
"vscjava.vscode-gradle",
"ms-vscode.vscode-json",
"streetsidesoftware.code-spell-checker"
],
"settings": {
"java.configuration.runtimes": [
{
"name": "JavaSE-21",
"path": "/usr/local/openjdk-21"
}
],
"java.compile.nullAnalysis.mode": "automatic"
}
}
},
"containerEnv": {
"JAVA_HOME": "/usr/local/openjdk-21"
},
"remoteUser": "nessie",
"workspaceFolder": "/workspace",
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached"
],
"forwardPorts": [19120],
"portsAttributes": {
"19120": {
"label": "Nessie Server",
"onAutoForward": "notify"
}
},
"postCreateCommand": "./gradlew --version",
"remoteEnv": {
"PATH": "${containerEnv:PATH}:/usr/local/openjdk-21/bin"
}
}
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ non-obvious platform differences.

TL;DR It is fine to build code on macOS and Windows, but the reference platform is Linux.

#### Development Container

If you prefer not to develop on the metal, Nessie provides a VSCode `devcontainers` development container
configuration that creates an isolated Linux environment with all required tools pre-installed.

**Quick Start:**
(Assumes you are using [VS Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) )
1. Open the project in VS Code
2. When prompted, click "Reopen in Container" or use `Ctrl+Shift+P` → "Dev Containers: Reopen in Container"
3. Wait for the container to build and start developing!

For detailed instructions and manual Docker usage, see [`.devcontainer/README.md`](.devcontainer/README.md).

#### Running tests on macOS

In our CI we use Podman for macOS, initialized using the following sequence of commands,
Expand Down