Skip to content

S update docker #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 28, 2025
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
134 changes: 134 additions & 0 deletions .devcontainer/build_image_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Building and Publishing the Docker Image

This guide shows how to build the DoubleML documentation development container locally and publish it to Docker Hub.

## Prerequisites

- [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed and running
- Access to the `svenklaassen` [Docker Hub](https://www.docker.com/products/docker-hub/) account
- [doubleml-docs](https://github.com/DoubleML/doubleml-docs) repository cloned to your local machine

## Step 1: Login to Docker Hub

Open a terminal and login to Docker Hub:

```bash
docker login
```

Enter the Docker Hub username (`svenklaassen`) and password (or token) when prompted.

## Step 2: Build the Docker Image

Navigate to your project root directory and build the image (using the `latest`-tag):

```bash
docker build -t svenklaassen/doubleml-docs:latest -f .devcontainer/Dockerfile.dev .
```

To force a complete rebuild without using cache:

```bash
docker build --no-cache -t svenklaassen/doubleml-docs:latest -f .devcontainer/Dockerfile.dev .
```

## Step 3 (Optional): Verify the image

### Open the repository in VS Code

1. Ensure your `.devcontainer/devcontainer.json` is configured to use your local image:

```json
"image": "svenklaassen/doubleml-docs:latest"
```
Note: The `.devcontainer/devcontainer.json` file is configured to use the pre-built image. If you want to build the container from scratch, uncomment the `dockerFile` and `context` lines and comment out the `image` line.

2. Open the `doubleml-docs` repository in VS Code:

```bash
code /path/to/doubleml-docs
```

3. Open the Command Palette (`Ctrl+Shift+P`) and select `Dev Containers: Reopen in Container`.
VS Code will use your locally built image.

### Build the documentation

Once inside the container, verify that you can successfully build the documentation:

1. Open a terminal in VS Code (`Terminal > New Terminal`)

2. Build the documentation:

```bash
cd doc
make html
```

3. Check the output for any errors or warnings

4. View the built documentation by opening the output files:

```bash
# On Windows
explorer.exe _build/html

# On Linux
xdg-open _build/html

# On macOS
open _build/html
```

If the documentation builds successfully and looks correct, your Docker image is working properly and ready to be pushed to Docker Hub.

## Step 4: Push to Docker Hub

Push your built image to Docker Hub:

```bash
docker push svenklaassen/doubleml-docs:latest
```

## Step 5: Using the Published Image

After publishing, there are two ways to use the image:

### Option 1: Manual Container Management
Pull and run the container manually:

```bash
docker pull svenklaassen/doubleml-docs:latest
# Then run commands to create a container from this image
```

### Option 2: VS Code Integration (Recommended)
Simply reference the image in your `devcontainer.json` file:

```json
"image": "svenklaassen/doubleml-docs:latest"
```

VS Code will automatically pull the image when opening the project in a container - no separate `docker pull` command needed.

## Troubleshooting

### Clear Docker Cache

If you're experiencing issues with cached layers:

```bash
# Remove build cache
docker builder prune

# For a more thorough cleanup
docker system prune -a
```

### Check Image Size

To verify the image size before pushing:

```bash
docker images svenklaassen/doubleml-docs
```
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "DoubleML Documentation Development",
"dockerFile": "Dockerfile.dev", // Path to your Dockerfile
"context": "..", // Context for the build (root of your project)
"image": "svenklaassen/doubleml-docs:latest",
// "dockerFile": "Dockerfile.dev",
// "context": "..",
"workspaceFolder": "/workspace", // Folder inside the container for your project
// Customizations for VS Code
"customizations": {
Expand Down
83 changes: 83 additions & 0 deletions .devcontainer/docker_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Build Documentation with Development Container

This guide shows how to use WSL2 (Windows Subsystem for Linux), Docker Desktop, Visual Studio Code (VS Code), and how to work with Development Containers in VS Code on a Windows machine.

Requirements:
- [VS Code](https://code.visualstudio.com/)
- [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install)
- [Docker Desktop](https://docs.docker.com/desktop/setup/install/windows-install/)

## Step 1: Verify installations & Setup

You can verify the installations in a terminal:

```bash
code --version
wsl --version
docker --version
```

### Configure Docker to Use WSL2

See [Docker Desktop Documentation](https://docs.docker.com/desktop/features/wsl/#turn-on-docker-desktop-wsl-2).
1. Open Docker Desktop.
2. Go to **Settings > General** and make sure **Use the WSL 2 based engine** is checked.
3. Under **Settings > Resources > WSL Integration**, ensure that your desired Linux distribution(s) are selected for integration with Docker.

### Install Extensions

1. Open Visual Studio Code.
2. Press `Ctrl+Shift+X` to open the Extensions view.
3. Search and install (includes WSL and Dev Containers Extensions):
- [Remote Development Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)

Helpful VS Code Documentations:
- [Developing in WSL](https://code.visualstudio.com/docs/remote/wsl)
- [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers)


## Step 2: Open the Development Container (Using Pre-built Image)

For faster setup, we'll use a pre-built Docker image:

1. Open the `doubleml-docs` repository in VS Code:

```bash
code /path/to/doubleml-docs
```

2. Open the Command Palette (`Ctrl+Shift+P`).
3. Type `Dev Containers: Reopen in Container`.

VS Code will pull the `svenklaassen/doubleml-docs:latest` image (if needed) based on `devcontainer.json` and open the project in the container.<br>
This approach is much faster than building the container from scratch. VS Code automatically downloads the image from Docker Hub if it's not already on your system.


## Step 3: Build the documentation

1. Open a terminal in VS Code (`Terminal > New Terminal`)

2. Build the documentation:

```bash
cd doc
make html
```

To build without notebook examples:
```bash
make html NBSPHINX_EXECUTE=never
```

3. View the built documentation by opening the output files:

```bash
# On Windows
explorer.exe _build/html

# On Linux
xdg-open _build/html

# On macOS
open _build/html
```
64 changes: 0 additions & 64 deletions .devcontainer/guide.md

This file was deleted.

Loading