Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .expeditor/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ subscriptions:
pipelines:
- verify:
description: Pull Request validation tests
public: true
- habitat/build:
env:
- HAB_NONINTERACTIVE: "true"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
coverage-test:
name: Coverage
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up ruby 3.1
Expand Down
9 changes: 9 additions & 0 deletions dev/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Use official Ruby image from Docker Hub
# Update if you need to use a different version of ruby. source: https://hub.docker.com/_/ruby/tags
FROM ruby:3.1.2

# Set working directory
WORKDIR /workspace

# Default command to keep container running
CMD ["sleep", "infinity"]
24 changes: 24 additions & 0 deletions dev/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use Windows Server Core LTSC 2022
FROM mcr.microsoft.com/windows/servercore:ltsc2022

# Set default Ruby version (overridable at runtime)
# this is a choco package list
ARG rubyVersion=3.1.2.1
ENV RUBY_VERSION=${rubyVersion}

# Install Chocolatey (Windows package manager)
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install Ruby via Chocolatey using the environment variable
RUN powershell -Command "choco install ruby --version=$env:RUBY_VERSION -y"

# Add Ruby to PATH
ENV PATH="C:\\tools\\ruby${RUBY_VERSION}\\bin;${PATH}"

# # Verify Ruby installation
# RUN ruby --version

# Set working directory
WORKDIR C:\\workspace

# Default command to keep container running
CMD ["powershell", "-Command", "Start-Sleep -Seconds 86400"]
100 changes: 100 additions & 0 deletions dev/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Ruby Development Environment with Docker
---

# **Ruby Development with Docker (Linux & Windows Containers)**

## **Overview**
This project provides **Docker containers** for Ruby development on both **Linux** and **Windows** environments.

- 🐧 **Linux Container**: Uses the official [`ruby:3.1.2`](https://hub.docker.com/_/ruby) Docker image for a lightweight setup.
- 🖥️ **Windows Container**: Based on **Windows Server Core LTSC 2022**, installing Ruby via **Chocolatey**.

---

## **System Requirements**
### **For Linux/macOS users (WSL2 or native Linux/macOS)**
✅ Docker Desktop with **Linux containers enabled**
✅ macOS/Linux terminal (or WSL2 for Windows users)

### **For Windows users**
✅ Docker Desktop with **Windows containers enabled**
✅ Windows 10/11 (Pro, Enterprise, or Education)

---

## **How to Build the Containers**

### **Building the Linux Container**
```sh
docker build -t ruby-linux -f Dockerfile.linux .
```

### **Building the Windows Container**
```powershell
docker build -t ruby-windows -f Dockerfile.windows .
```

To specify a **different Ruby version**, use `--build-arg`:
```sh
docker build --build-arg rubyVersion=3.2.0 -t ruby-linux -f Dockerfile.linux .
```
```powershell
docker build --build-arg rubyVersion=3.2.0 -t ruby-windows -f Dockerfile.windows .
```

---

## **How to Run the Containers**

### **Running the Linux Container**
```sh
docker run -it --rm -v $(pwd):/workspace ruby-linux bash
```
- Mounts the current project directory to `/workspace` inside the container.
- Starts an interactive shell session.

### **Running the Windows Container**
```powershell
docker run -it --rm -v ${PWD}:/workspace ruby-windows powershell
```
- Mounts the project directory as `C:\workspace`.
- Starts an interactive PowerShell session.

---

## **Switching Between Windows and Linux Containers**
⚠ **IMPORTANT:** Docker **cannot run both Linux and Windows containers simultaneously**. If you're switching between them:

### **Switch to Linux Containers**
1. Open **Docker Desktop**.
2. Click the **Settings** ⚙️ icon.
3. Under **General**, check **"Use the WSL 2 based engine"**.
4. Right-click the Docker icon in the system tray → **Switch to Linux containers**.

### **Switch to Windows Containers**
1. Right-click the **Docker Desktop** icon in the system tray.
2. Select **"Switch to Windows containers"**.

---

## **Verifying Ruby Installation**
Once inside a running container, check the installed Ruby version:
```sh
ruby -v
```

---

## **Troubleshooting**
❌ **Issue:** "Cannot switch to Windows/Linux containers"
✅ **Solution:** Restart **Docker Desktop** and try again.

❌ **Issue:** "Mounting volume fails on Windows"
✅ **Solution:** Ensure **file sharing** is enabled in Docker settings under **Resources > File Sharing**.

❌ **Issue:** "Exception calling "DownloadString" with "1" argument(s): "The remote name could not be resolved: 'community.chocolatey.org'"
✅ **Solution:** Ensure **Docker network ls** is using the correct network.
- docker network ls
- docker network inspect "name"
- use the right network: docker build --network="NameOfNetwork" -t ruby-windows -f
---
Loading