Skip to content

Commit c10263f

Browse files
3vilhamstergazi-yestemirova
authored andcommitted
Introduce VSCode Remote Containers usage (cadence-workflow#513)
* Downgrading locks with a proper npm * Introduce .devcontainer for dockerize development using VSCode * make docker-compose up start local server by default * updated contributing, readme guides with link to Remove containers and updated Dockerfile to ensure we do not modify lock file during building container
1 parent 957b4b3 commit c10263f

File tree

9 files changed

+170
-31688
lines changed

9 files changed

+170
-31688
lines changed

.devcontainer/devcontainer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3+
{
4+
"name": "Existing Docker Compose (Extend)",
5+
6+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
7+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
8+
"dockerComposeFile": [
9+
"../docker-compose.yml",
10+
"docker-compose.yml"
11+
],
12+
13+
// The 'service' property is the name of the service for the container that VS Code should
14+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
15+
"service": "base",
16+
17+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
18+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
19+
"workspaceFolder": "/usr/src/service",
20+
21+
// Features to add to the dev container. More info: https://containers.dev/features.
22+
// "features": {},
23+
24+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25+
"forwardPorts": [8088,8090],
26+
27+
// Uncomment the next line if you want start specific services in your Docker Compose config.
28+
// "runServices": []
29+
30+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
31+
// "shutdownAction": "none",
32+
33+
// Uncomment the next line to run commands after the container is created.
34+
"postCreateCommand": "npm install --no-save --unsafe-perm"
35+
36+
// Configure tool-specific properties.
37+
// "customizations": {},
38+
39+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
40+
// "remoteUser": "devcontainer"
41+
}

.devcontainer/docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3'
2+
services:
3+
# Update this to the name of the service you want to work with in your docker-compose.yml file
4+
base:
5+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
6+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
7+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
8+
# array). The sample below assumes your primary file is in the root of your project.
9+
#
10+
# build:
11+
# context: .
12+
# dockerfile: .devcontainer/Dockerfile
13+
14+
# volumes:
15+
# # Update this to wherever you want VS Code to mount the folder of your project
16+
# - ..:/usr/src/service
17+
18+
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
19+
# cap_add:
20+
# - SYS_PTRACE
21+
# security_opt:
22+
# - seccomp:unconfined
23+
24+
# Overrides default command so things don't shut down after the process ends.
25+
command: /bin/sh -c "while sleep 1000; do :; done"
26+

.docker_env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
NODE_ENV=development
2+
CADENCE_TCHANNEL_PEERS="localhost:16232"
3+
CADENCE_TCHANNEL_SERVICE=cadence-frontend
4+
CADENCE_WEB_PORT=8088
5+
CADENCE_EXTERNAL_SCRIPTS=""
6+
ENABLE_AUTH=false
7+
AUTH_TYPE=""
8+
AUTH_ADMIN_JWT_PRIVATE_KEY=""

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ This doc is intended for contributors to `cadence-web`
66

77
## Development Environment
88

9-
Node.js. Check [package.json](https://github.com/uber/cadence-web/blob/master/package.json) for the current version required. We recommend using [nvm](https://github.com/creationix/nvm) to manage your versions.
9+
Node.js. Check [package.json](https://github.com/uber/cadence-web/blob/master/package.json) for the current version required. We do not recomment nvm since it can provide confusion with npm version.
10+
11+
For development we recommend using VSCode with [Remote Containers plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). We provide a default configuration for remote container using docker-compose.
1012

1113
You also need to run [cadence-server](https://github.com/uber/cadence) locally or have access to a cadence environment to talk to.
1214

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ WORKDIR /usr/build
77
COPY . .
88

99
# Install app dependencies
10-
RUN npm install --production --unsafe-perm
10+
RUN npm install --no-save --production --unsafe-perm
1111

1212
# Bundle the client code
1313
RUN npm run build-production
@@ -31,4 +31,4 @@ ENV NPM_CONFIG_PRODUCTION=true
3131

3232
# run node server
3333
EXPOSE 8088
34-
CMD [ "node", "server.js" ]
34+
CMD [ "node", "server.js" ]

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ Set these environment variables if you need to change their defaults
2727
### Running locally
2828

2929
`cadence-web` requires node `v10.22.1` or greater to be able to run correctly. `cadence-web` uses all the standard [npm scripts](https://docs.npmjs.com/misc/scripts) to install dependencies, run the
30-
server, and run tests. Additionally to run locally with webpack hot reloading and other conveniences, use
30+
server, and run tests. To provide a consistent environment we recommend using docker in development.
31+
To start local server with live reload on code change you can run:
3132

3233
```
33-
npm run dev
34+
docker-compose up
3435
```
3536

37+
For development we recommend using VSCode with [Remote Containers plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). We provide a default configuration for remote container using docker-compose.
38+
3639
For development and contributing to `cadence-web`, please see the [contributing guide](https://github.com/uber/cadence-web/blob/master/CONTRIBUTING.md).
3740

3841
You may also use docker by pulling [ubercadence/web](https://hub.docker.com/r/ubercadence/web/). It is also included in the Cadence server's [local docker setup](https://github.com/uber/cadence/tree/master/docker).

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3'
2+
services:
3+
base:
4+
env_file:
5+
- .docker_env
6+
image: node:fermium-bullseye
7+
volumes:
8+
- .:/usr/src/service
9+
working_dir: /usr/src/service
10+
command: npm run dev
11+
install:
12+
extends:
13+
base
14+
command: /bin/sh -c "npm install --no-save --unsafe-perm && npm run dev"

0 commit comments

Comments
 (0)