Skip to content

Commit 53c4524

Browse files
committed
Add devcontainer configuration
1 parent 55c38a3 commit 53c4524

File tree

4 files changed

+196
-0
lines changed

4 files changed

+196
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Use a Ruby image >= 3.1, as required by some dependencies like recent nokogiri
2+
FROM ruby:3.2-slim-bookworm
3+
4+
# Prevent interactive prompts from apt
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Install system dependencies required for building gems with native extensions
8+
# and for general development.
9+
# - build-essential: For compiling native extensions
10+
# - git: For cloning repos if needed, although VS Code handles the main clone
11+
# - curl, wget: Useful general tools
12+
# - libxml2-dev, libxslt1-dev: Needed by nokogiri gem
13+
# - zlib1g-dev: Needed by many gems
14+
# - sqlite3, libsqlite3-dev: Needed by some gems that might be transitively included
15+
# - libssl-dev: Needed for secure connections, potentially by some gems
16+
# - pkg-config: Build helper
17+
# - make: Used by the Makefile in the repo
18+
RUN apt-get update && apt-get install -y --no-install-recommends \
19+
build-essential \
20+
git \
21+
curl \
22+
wget \
23+
libxml2-dev \
24+
libxslt1-dev \
25+
zlib1g-dev \
26+
sqlite3 \
27+
libsqlite3-dev \
28+
libssl-dev \
29+
pkg-config \
30+
make \
31+
zsh \
32+
&& apt-get clean \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
36+
# (Optional but Recommended) Create a non-root user for development
37+
# This matches the default user setup by Dev Containers 'automatic' creation
38+
ARG USERNAME=vscode
39+
ARG USER_UID=1000
40+
ARG USER_GID=$USER_UID
41+
42+
RUN groupadd --gid $USER_GID $USERNAME \
43+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
44+
# Add the new user to the sudo group to allow them to run commands with sudo
45+
&& apt-get update \
46+
&& apt-get install -y sudo \
47+
&& echo $USERNAME ALL=\(ALL\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
48+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
49+
&& rm -rf /var/lib/apt/lists/*
50+
51+
# Set Zsh as the default shell for the non-root user
52+
# Needs to be run as root, after the user is created and zsh is installed
53+
RUN chsh -s $(which zsh) ${USERNAME}
54+
55+
# Set the default working directory for subsequent commands and where the project code will be mounted
56+
WORKDIR /workspaces
57+
58+
# Switch to the non-root user
59+
USER $USERNAME
60+
61+
# The project code will be mounted into /workspaces by Dev Containers.
62+
# Dependencies will be installed via postCreateCommand in devcontainer.json

.devcontainer/devcontainer.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// .devcontainer/devcontainer.json
2+
{
3+
"name": "Fluent Plugin Datadog Dev", // A friendly name
4+
// Specify the path to the custom Dockerfile
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
// Use the non-root user created in the Dockerfile
9+
"remoteUser": "vscode",
10+
// Set the workspace folder inside the container
11+
"workspaceFolder": "/workspaces/fluent-plugin-datadog",
12+
// Command to run after the container is created and the workspace is mounted.
13+
// This installs the gem dependencies using Bundler.
14+
"postCreateCommand": "bundle install && sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\"",
15+
// Forward ports that might be useful (e.g., for testing Fluentd)
16+
// Fluentd's default forward port is 24224. The repo's docker-compose also uses this.
17+
"forwardPorts": [
18+
24224
19+
],
20+
// Configuration specific to VS Code
21+
"customizations": {
22+
"vscode": {
23+
"settings": {
24+
// Optional: Configure Ruby environment settings if needed
25+
"ruby.useBundler": true,
26+
"ruby.lint": {
27+
"rubocop": true
28+
},
29+
"ruby.format": "rubocop",
30+
// Add other Ruby or general settings here
31+
// Configure VS Code's integrated terminal to use Zsh
32+
"terminal.integrated.defaultProfile.linux": "zsh (2)",
33+
"terminal.integrated.profiles.linux": {
34+
"zsh (2)": {
35+
"path": "zsh"
36+
}
37+
}
38+
},
39+
// Specify VS Code extensions to install automatically
40+
"extensions": [
41+
"rebornix.ruby", // Official Ruby extension
42+
"bungcip.better-toml", // For TOML config files
43+
"kaiinui.vscode-ruby-test-explorer", // If you want a test explorer UI
44+
"dbaeumer.vscode-eslint", // If there are JS parts or linting
45+
"redhat.vscode-yaml", // For YAML files (like the docker-compose)
46+
"ms-azuretools.vscode-docker" // Useful for working with Docker inside VS Code
47+
// Add any other extensions relevant to your workflow
48+
]
49+
}
50+
}
51+
// Uncomment to connect as root instead of the remoteUser.
52+
// "remoteUser": "root"
53+
}

.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Run Fluentd with Datadog Plugin",
6+
"type": "node",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/bin/fluentd",
9+
"args": [
10+
"-c",
11+
"${workspaceFolder}/test/fluentd.conf",
12+
"-p",
13+
"${workspaceFolder}/lib/fluent/plugin"
14+
],
15+
"env": {
16+
"FLUENTD_DISABLE_BUNDLER_INJECTION": "1"
17+
}
18+
},
19+
{
20+
"name": "Run Tests",
21+
"type": "node",
22+
"request": "launch",
23+
"program": "${workspaceFolder}/bin/rake",
24+
"args": ["test"]
25+
}
26+
]
27+
}

.vscode/tasks.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Install Dependencies",
6+
"type": "shell",
7+
"command": "bundle install",
8+
"group": "build",
9+
"presentation": {
10+
"reveal": "always",
11+
"panel": "new"
12+
},
13+
"problemMatcher": []
14+
},
15+
{
16+
"label": "Build Gem",
17+
"type": "shell",
18+
"command": "gem build fluent-plugin-datadog.gemspec",
19+
"group": {
20+
"kind": "build",
21+
"isDefault": true
22+
},
23+
"presentation": {
24+
"reveal": "always",
25+
"panel": "new"
26+
},
27+
"problemMatcher": [],
28+
"dependsOn": ["Install Dependencies"]
29+
},
30+
{
31+
"label": "Run Tests",
32+
"type": "shell",
33+
"command": "bundle exec rake test",
34+
"group": "test",
35+
"presentation": {
36+
"reveal": "always",
37+
"panel": "new"
38+
},
39+
"problemMatcher": []
40+
},
41+
{
42+
"label": "Build and Test",
43+
"dependsOn": [
44+
"Install Dependencies",
45+
"Build Gem",
46+
"Run Tests"
47+
],
48+
"group": {
49+
"kind": "build",
50+
"isDefault": false
51+
}
52+
}
53+
]
54+
}

0 commit comments

Comments
 (0)