-
Notifications
You must be signed in to change notification settings - Fork 7
Introduce devcontainer service container based development environment (#705)
#706
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
base: master
Are you sure you want to change the base?
Changes from all commits
1ef9f0b
dae197b
cae210f
3195ad6
92e80ca
8cf087b
b0cee5f
58cd4e5
1bf514f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "name": "React UI (${localWorkspaceFolderBasename})", | ||
| "initializeCommand": "bash ./setup.sh", | ||
| "dockerComposeFile": [ | ||
| "../docker-compose.yml" | ||
| ], | ||
| "service": "devcontainer", | ||
| "shutdownAction": "stopCompose", | ||
| "workspaceFolder": "/workspace", | ||
| "forwardPorts": [ | ||
| "docs:8000" | ||
| ], | ||
| "portsAttributes": { | ||
| "docs:8000": { | ||
| "label": "Docs server", | ||
| "protocol": "http", | ||
| "onAutoForward": "openBrowser" | ||
| } | ||
| }, | ||
| "otherPortsAttributes": { | ||
| "onAutoForward": "ignore" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,52 @@ | ||
| ############################### | ||
| # Docker compose configuration # | ||
| ############################### | ||
| ################################ | ||
| # Docker Compose configuration # | ||
| ################################ | ||
|
|
||
| # Host system port where the live documentation is to be made accessible | ||
| COMPOSE_START_PORT=8000 | ||
| # Docker compose project name must match directory name of the project to allow devcontainer to communicate with other containers | ||
| COMPOSE_PROJECT_NAME=react-ui | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is magic propagated to other scripts allowing you to run multiple instances of same repository without conflicting. $COMPOSE_PROJECT_NAME is used where needed. Check |
||
|
|
||
| # Host system port where Playwright Component Testing report is to be made accessible | ||
| # Docker compose ports for Docs server instances | ||
| COMPOSE_START_DOCS_SERVER_PORT=8000 | ||
|
|
||
| # Docker compose ports for Playwright Component Testing report server | ||
| COMPOSE_PLAYWRIGHT_REPORT_PORT=9323 | ||
|
|
||
| # Flag whether to start JavaScript files watcher at container start | ||
| COMPOSE_START_JS_FILES_WATCHER_AT_START=true | ||
|
|
||
| # Flag whether to start docs server at container start | ||
| COMPOSE_START_DOCS_SERVER_AT_START=true | ||
|
|
||
| # Ownership of the files created in the container | ||
| # ⚠️ [Linux] This needs to be set to the output of `id --user` | ||
| # ⚠️ [MacOS] This needs to be set to 1000 | ||
| COMPOSE_UID=1000 | ||
| # ⚠️ [Linux] This needs to be set to the output of `id --group` | ||
| # ⚠️ [MacOS] This needs to be set to 1000 | ||
| COMPOSE_GID=1000 | ||
|
|
||
| ############################# | ||
| # Devcontainer configuration # | ||
| ############################# | ||
|
|
||
| # IDEs automatically mount the host's SSH agent socket into the container | ||
| # Visual Studio Code does this by default, it can be disabled by setting the following variable to true. | ||
| # JetBrains IDEs do not mount this by default, but they can be configured to do so. | ||
| BLOCK_SSH_AUTH_SOCK=false | ||
|
|
||
| # Select your preferred editor and visual (vim, nano) | ||
| EDITOR=vim | ||
| VISUAL=vim | ||
|
|
||
| # Select your preferred shell (/bin/bash, /bin/fish, /bin/zsh) | ||
| SHELL=/bin/bash | ||
|
|
||
| ########################### | ||
| # Playwright configuration # | ||
| ########################### | ||
|
|
||
| # Number of workers to use to run Playwright tests | ||
| PW_WORKERS=1 | ||
|
|
||
| # Port used by Playwright Component Testing to serve the test files | ||
| PW_CT_PORT=3100 | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| /coverage | ||
| /docker-compose.yml | ||
| /docker/react_ui_devcontainer_local | ||
| !/docker/react_ui_devcontainer_local/Dockerfile.dist | ||
| /dist | ||
| /node_modules | ||
| /playwright-report/ | ||
| /site | ||
| /src/docs/_assets/generated/* | ||
| /tests/playwright/.temp/ | ||
| .env | ||
| .env.playwright | ||
| statistics.html | ||
| !.gitkeep |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||
| services: | ||||||
| # This service is responsible for providing the main development environment for developers | ||||||
| devcontainer: | ||||||
| hostname: ${COMPOSE_PROJECT_NAME:-react-ui}_devcontainer | ||||||
| build: | ||||||
| context: docker/react_ui_devcontainer/ | ||||||
| dockerfile: Dockerfile | ||||||
| # Start dependent services before starting the `devcontainer` service to ensure that the necessary environments | ||||||
| # and tools are available when the `devcontainer` starts. | ||||||
| depends_on: | ||||||
| node: | ||||||
| condition: service_started | ||||||
| playwright: | ||||||
| condition: service_started | ||||||
| docs: | ||||||
| condition: service_started | ||||||
| user: ${COMPOSE_UID}:${COMPOSE_GID} | ||||||
|
||||||
| user: ${COMPOSE_UID}:${COMPOSE_GID} | |
| user: developer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have already tested it in private project and it works on Linux and MacOS as well correctly. So I am not sure if copilot note is right or not. @mbohal?
Copilot
AI
Mar 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The node service runs npm ci on every container start when COMPOSE_START_JS_FILES_WATCHER_AT_START=true (default in .env.dist). This makes docker compose up / Dev Container startup significantly slower and repeatedly wipes/reinstalls node_modules. Consider running npm ci only when needed (e.g., when node_modules is missing or package-lock.json changed), or splitting dependency install into an explicit setup step and having the startup command just run npm start.
| command: sh -c 'if [ "$$COMPOSE_START_JS_FILES_WATCHER_AT_START" = "true" ]; then npm ci && npm start; else sleep infinity; fi' | |
| command: sh -c 'if [ "$$COMPOSE_START_JS_FILES_WATCHER_AT_START" = "true" ]; then if [ ! -d node_modules ] || [ package-lock.json -nt node_modules ]; then npm ci; fi; npm start; else sleep infinity; fi' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it this way so user always have up-to-date environment. It is same as with rebuilding images, in first phase, I did it this way. But if you want @adamkudrna, I can add check that it is executed only if node_modules does not exist (I need to make sure deps are installed prior to npm start)
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| services: | ||
| # This service is responsible for providing the main development environment for developers | ||
| devcontainer: | ||
| extends: | ||
| file: docker-compose.base.yml | ||
| service: devcontainer | ||
| # Use `build` when you want to customize the devcontainer using `docker/react_ui_devcontainer_local/Dockerfile` | ||
| # build: | ||
| # context: ./docker/react_ui_devcontainer_local/ | ||
| # dockerfile: Dockerfile | ||
| # Use `image` when you want to use the default devcontainer | ||
| image: react-ui_devcontainer | ||
|
|
||
| # This service provides Node environment and NPM | ||
| node: | ||
| extends: | ||
| file: docker-compose.base.yml | ||
| service: node | ||
|
|
||
| # This service provides Playwright environment and tools for browser automation and testing | ||
| playwright: | ||
| extends: | ||
| file: docker-compose.base.yml | ||
| service: playwright | ||
|
|
||
| # This provides server for documentation | ||
| docs: | ||
| extends: | ||
| file: docker-compose.base.yml | ||
| service: docs | ||
|
|
||
| volumes: | ||
| # The following volumes are used to persist data (e.g. terminal history, AI tools data, etc.) across container restarts | ||
| terminal-history: | ||
| claude-config: | ||
| claude-share: | ||
| claude-state: | ||
| copilot: | ||
| copilot-config: | ||
| opencode-config: | ||
| opencode-share: | ||
| opencode-state: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
| trap 'echo "Failed to build Docker images"; exit 1' ERR | ||
bedrich-schindler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| cd "$(dirname "$0")" | ||
|
|
||
| echo "Building Docker images..." | ||
|
|
||
| if [ ! -f ../.env ]; then | ||
| echo "Error: .env file not found in the project root" | ||
| exit 1 | ||
| fi | ||
|
|
||
| PROJECT_NAME=$(grep -E '^COMPOSE_PROJECT_NAME=' ../.env | cut -d '=' -f 2-) | ||
| PROJECT_DEVCONTAINER_IMAGE="${PROJECT_NAME}_devcontainer" | ||
|
|
||
| echo "Building Docker image $PROJECT_DEVCONTAINER_IMAGE..." | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for info: This is needed if we want ability to allow user to specify his/her local Dockerfile (Dockerfile cannot extend from other Dockerfile, just from Docker image). This can look like a non sense, but this is the best I want able to come up with. |
||
| docker build -t "$PROJECT_DEVCONTAINER_IMAGE" -f ./react_ui_devcontainer/Dockerfile ./react_ui_devcontainer/ | ||
bedrich-schindler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| cd .. | ||
|
|
||
| echo "Building project Docker images using docker-compose..." | ||
| docker compose build | ||
|
|
||
bedrich-schindler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| echo "All Docker images built successfully!" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for info: This was requested by @mbohal who usually have multiple instances of a repository on his machine. This allow to differ between multiple versions by directory name.