diff --git a/README.md b/README.md index 0fd0e25a7e3..424d7109038 100644 --- a/README.md +++ b/README.md @@ -224,22 +224,19 @@ sudo chown $USER /var/lib/teleport ### Web UI -The Teleport Web UI resides in the [Gravitational Webapps](https://github.com/gravitational/webapps) repo. +The Teleport Web UI resides in the [web](web) directory. #### Rebuilding Web UI for development -To clone this repository and rebuild the Teleport UI package, run the following commands: +To rebuild the Teleport UI package, run the following command: ```bash -git clone git@github.com:gravitational/webapps.git -cd webapps -make build-teleport +make docker-ui ``` Then you can replace Teleport Web UI files with the files from the newly-generated `/dist` folder. -To enable speedy iterations on the Web UI, you can run a -[local web-dev server](https://github.com/gravitational/webapps/tree/master/packages/teleport). +To enable speedy iterations on the Web UI, you can run a [local web-dev server](web#web-ui). You can also tell Teleport to load the Web UI assets from the source directory. To enable this behavior, set the environment variable `DEBUG=1` and rebuild with the default target: @@ -250,7 +247,7 @@ DEBUG=1 ./build/teleport start -d ``` Keep the server running in this mode, and make your UI changes in `/dist` directory. -For instructions about how to update the Web UI, read [the `webapps` README](https://github.com/gravitational/webapps/blob/master/README.md) file. +For instructions about how to update the Web UI, read [the `web` README](web#readme). #### Updating Web UI assets diff --git a/web/tsconfig.json b/tsconfig.json similarity index 77% rename from web/tsconfig.json rename to tsconfig.json index b3988ba3afb..c3c6f2e8042 100644 --- a/web/tsconfig.json +++ b/tsconfig.json @@ -25,31 +25,31 @@ ], "paths": { "grpc": [ - "../node_modules/@grpc/grpc-js" + "node_modules/@grpc/grpc-js" ], // generator still uses "grpc" package that has been deprecated in favor of "@grpc/grpc-js" "shared/*": [ - "packages/shared/*" + "web/packages/shared/*" ], "design/*": [ - "packages/design/src/*" + "web/packages/design/src/*" ], "design": [ - "packages/design/src/" + "web/packages/design/src/" ], "teleport/*": [ - "packages/teleport/src/*" + "web/packages/teleport/src/*" ], "teleport": [ - "packages/teleport/src/" + "web/packages/teleport/src/" ], "teleterm/*": [ - "packages/teleterm/src/*" + "web/packages/teleterm/src/*" ], "e-teleport/*": [ - "../e/web/teleport/src/*" + "e/web/teleport/src/*" ], "e-teleterm/*": [ - "../e/web/teleterm/src/*" + "e/web/teleterm/src/*" ] } }, @@ -61,4 +61,4 @@ "**/build/app/**", "**/build/release/**" ] -} \ No newline at end of file +} diff --git a/web/Dockerfile b/web/Dockerfile deleted file mode 100644 index 4590cb70486..00000000000 --- a/web/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM node:16.18-slim -RUN apt-get update && apt-get install git g++ make python3 tree -y - -RUN mkdir -p web-apps -COPY yarn.lock web-apps/ -COPY package.json web-apps/ -COPY tsconfig.json web-apps/ -# copy entire build package as it has required .bin files -COPY packages/build/ web-apps/packages/build/ - -# copy only package.json files -COPY packages/design/package.json web-apps/packages/design/ -COPY packages/shared/package.json web-apps/packages/shared/ -COPY packages/teleport/package.json web-apps/packages/teleport/ -COPY packages/teleterm/package.json web-apps/packages/teleterm/ - -# copy enterprise package.json files if present -COPY README.md packages/webapps.e/telepor[t]/package.json web-apps/packages/webapps.e/teleport/ - -# download and install npm dependencies -WORKDIR web-apps -ARG YARN_FROZEN_LOCKFILE -RUN if [ -n "$YARN_FROZEN_LOCKFILE" ]; then \ - ./packages/build/scripts/yarn-install-frozen-lockfile.sh; \ - else \ - yarn install; \ - fi - -# copy the rest of the files and run yarn build command -COPY . . - -ARG NPM_SCRIPT=nop -ARG OUTPUT -ARG CONNECT_TSH_BIN_PATH -ENV CONNECT_TSH_BIN_PATH=$CONNECT_TSH_BIN_PATH -# run npm script with optional --output-path parameter -RUN yarn $NPM_SCRIPT $([ -z $OUTPUT ] || echo --output-path=$OUTPUT) diff --git a/web/Makefile b/web/Makefile deleted file mode 100644 index f4eb999b3c4..00000000000 --- a/web/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# Some often referenced variables are declared below, to avoid repetition -IMAGE_NAME := web-apps -CONTAINER_NAME := web-apps-container-$(shell bash -c 'echo $$RANDOM') -ROOT = $(shell pwd) -BRANCH = $(shell git rev-parse --abbrev-ref HEAD) -COMMIT = $(shell git rev-parse --short HEAD) -COMMIT_DESC = $(shell git log --decorate=off --oneline -1) -COMMIT_URL = https://github.com/gravitational/webapps/commit/$(COMMIT) - -.PHONY: build -build: - @if [ -d "packages/webapps.e/" ]; then \ - $(MAKE) docker-build NPM_CMD=build-teleport FROM=dist/ TO=dist/; \ - else \ - $(MAKE) docker-build NPM_CMD=build-oss FROM=dist/ TO=dist/; \ - fi; - -.PHONY: test -test: - $(MAKE) docker-build NPM_CMD=test - -.PHONY: build-teleport-oss -build-teleport-oss: - $(MAKE) docker-build NPM_CMD=build-teleport-oss FROM=dist/teleport/ TO=dist/teleport - -.PHONY: build-teleport-e -build-teleport-e: - $(MAKE) docker-build NPM_CMD=build-teleport-e FROM=dist/e/teleport/ TO=dist/e/teleport; - -.PHONY: build-teleport -build-teleport: - $(MAKE) docker-build NPM_CMD=build-teleport FROM=dist/ TO=dist/; - -# builds package dists files in docker (TODO: move it to scripts/docker-build.sh) -.PHONY: docker-build -docker-build: - docker build --force-rm=true --build-arg NPM_SCRIPT=$(NPM_CMD) -t $(IMAGE_NAME) . - @if [ "$(TO)" != "" ] || [ "$(FROM)" != "" ]; then \ - mkdir -p $(ROOT)/$(TO); \ - docker create --name $(CONTAINER_NAME) -t $(IMAGE_NAME) && \ - docker cp $(CONTAINER_NAME):/web-apps/$(FROM)/. $(ROOT)/$(TO); \ - docker rm -f $(CONTAINER_NAME); \ - fi; - -# docker-enter is a shorthand for entering the image -.PHONY: docker-enter -docker-enter: - docker run -ti --rm=true -t $(IMAGE_NAME) /bin/bash - -# docker-clean removes the existing image -.PHONY: docker-clean -docker-clean: - docker rmi --force $(IMAGE_NAME) - -# update-teleport-repo has moved -# it now lives here: https://github.com/gravitational/ops/tree/master/webapps/update-teleport-webassets.sh - -# clean removes this repo generated artifacts -.PHONY: clean -clean: - rm -rf dist teleport - find . -name "node_modules" -type d -prune -exec rm -rf '{}' + - -# init-submodules initializes / updates the submodules in this repo -.PHONY: init-submodules -init-submodules: - git submodule update --init --recursive diff --git a/web/README.md b/web/README.md index 17efe53b791..6ca4b880563 100644 --- a/web/README.md +++ b/web/README.md @@ -1,16 +1,14 @@ # Gravitational Web Applications and Packages -This mono-repository contains the source code for: +This directory contains the source code for: - the web UIs served by the `teleport` server - - [`packages/teleport`](packages/teleport) for the OSS version - - `packages/webapps.e/teleport` for the enterprise version + - [`packages/teleport`](packages/teleport) - the Electron app of [Teleport Connect](https://goteleport.com/connect/) - [`packages/teleterm`](packages/teleterm) - - `packages/webapps.e/teleterm` for the enterprise version The code is organized in terms of independent yarn packages which reside in -the [packages directory](https://github.com/gravitational/webapps/tree/master/packages). +the [packages directory](packages). ## Getting Started with Teleport Web UI @@ -30,22 +28,22 @@ $ yarn install To build the Teleport open source version ``` -$ yarn build-teleport-oss +$ yarn build-ui-oss ``` -The resulting output will be in the `/packages/{package-name}/dist/` folders respectively. +The resulting output will be in the `packages/{package-name}/dist/` folders respectively. ### Docker Build To build the Teleport community version ``` -$ make build-teleport-oss +$ make docker-ui ``` ## Getting Started with Teleport Connect -See [`README.md` in `packages/teleterm`](packages/teleterm). +See [`README.md` in `packages/teleterm`](packages/teleterm#readme). ## Development diff --git a/web/packages/build/webpack/webpack.base.js b/web/packages/build/webpack/webpack.base.js index 0f662d00b16..853440dbbba 100644 --- a/web/packages/build/webpack/webpack.base.js +++ b/web/packages/build/webpack/webpack.base.js @@ -24,7 +24,7 @@ const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); const resolvePath = require('./resolvepath'); -const tsconfigPath = path.join(__dirname, '/../../../tsconfig.json'); +const tsconfigPath = path.join(__dirname, '/../../../../tsconfig.json'); const configFactory = { createDefaultConfig,