Skip to content
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

Add DevContainers support for editing project locally #1506

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:20 AS base

USER 1000:1000
WORKDIR /app

# Install NPM dependencies
# Note: it mounts the cached ~/.npm folder generated by previous builds
# (docs: https://docs.npmjs.com/cli/v10/using-npm/config#cache)
COPY --chown=1000:1000 ./package.json ./package-lock.json /app/
RUN --mount=type=cache,mode=0700,uid=1000,gid=1000,target=/home/node/.npm \
npm ci

# Copy source files (ordered from least likely to be updated, up to the most likely)
COPY --chown=1000:1000 ./.eslintrc ./.lintstagedrc ./*.js /app/
COPY --chown=1000:1000 ./scripts /app/scripts/
COPY --chown=1000:1000 ./src /app/src/
COPY --chown=1000:1000 ./static /app/static/
COPY --chown=1000:1000 ./template /app/template/
COPY --chown=1000:1000 ./components /app/components/
COPY --chown=1000:1000 ./sidebars /app/sidebars/
COPY --chown=1000:1000 ./docs /app/docs/

FROM base AS dev
CMD ["npm", "start", "--", "--host=0.0.0.0", "--port=5000"]

14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Saleor Docs",
"dockerComposeFile": "docker-compose.yaml",
"service": "saleor-docs",
"workspaceFolder": "/app",
"forwardPorts": [
5000
],
"portsAttributes": {
"5000": {
"label": "Saleor Docs"
}
}
}
20 changes: 20 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
saleor-docs:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
restart: unless-stopped
ports:
- 127.0.0.1:5000:5000
volumes:
- ../components:/app/components/
- ../docs:/app/docs
- ../scripts:/app/scripts/
- ../sidebars:/app/sidebars/
- ../src:/app/src/
- ../static:/app/static/
- ../template:/app/template/
- ../sidebars.js:/app/sidebars.js
# Cache build to restart faster.
- ../.docusaurus:/app/.docusaurus

37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,46 @@

# What's In This Document

- [Get Started in 5 Minutes](#get-started-in-5-minutes)
- Installation
- [Using DevContainers for VSCode (Recommended)](#using-devcontainers-for-vscode-recommended)
- [Using Docker](#using-docker)
- [Using Node & NPM](#using-node--npm)
- [Directory Structure](#directory-structure)
- [Editing Content](#editing-content)
- [Adding Content](#adding-content)
- [Full Documentation](#full-docusaurus-documentation)

# Get Started in 5 Minutes
# Installation

## Using DevContainers for VSCode (Recommended)

> [!NOTE]
> - This requires docker or equivalent software to be installed and running on the machine.
> - Other editors than VSCode are supported: see the [official documentation](https://containers.dev/supporting)

Usage:

1. Install the [Dev Containers extension for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
2. Press F1 then run the command: `>dev containers: rebuild and Reopen in Container`
3. Once started, it should open a new VSCode workspace which should allow you to perform remote coding (against the container)
4. Go to `http://127.0.0.1:5000/` (may take up to a minute to load when opened for the first time)
5. When editing the code in VSCode, changes will reflect at `http://127.0.0.1:5000/` (may take a few seconds)

_More details are available in the official VSCode documentation: https://code.visualstudio.com/docs/devcontainers/containers#_getting-started_

## Using Docker

Steps:

1. Go under `.devcontainer/` folder
2. Run:
```bash
docker-compose up
```
3. Visit `http://127.0.0.1:5000/` (may take up to a minute to load when opened for the first time)
4. Any changes made to the files will reflect at `http://127.0.0.1:5000/` (may take a few seconds)

## Using Node & NPM

1. Make sure you are using Node in version 20+:

Expand Down
Loading
Loading