Skip to content

Commit

Permalink
*: add workshop cn guide (pingcap#992)
Browse files Browse the repository at this point in the history
Co-authored-by: mini-bot <liangzhiyuan@pingcap.com>
Co-authored-by: mini-bot-2 <88522432+mini-bot-2@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 7, 2022
1 parent 704fa00 commit 29237df
Show file tree
Hide file tree
Showing 8 changed files with 3,686 additions and 52 deletions.
11 changes: 8 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# Install additional OS packages.
RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& sudo apt-get -y install python3-pip python-dev jq mycli

# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"

# To install more global node packages.
RUN su node -c "npm install -g pnpm@7 ts-node typescript"

# Install Python depend dependencie.
RUN sudo pip3 install -U pip setuptools
RUN sudo pip3 install ipykernel pandas autopep8 Jinja2 mysql-connector-python

# Install TiUP cli, you can startup a TiDB cluster by `tiup playground` command.
RUN curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

# Install mycli, you can connect to the TiDB cluster.
RUN sudo apt update && sudo apt install -y mycli

43 changes: 29 additions & 14 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,61 @@
"build": {
"dockerfile": "Dockerfile"
},

// Set *default* container specific settings.json values on container create.
"settings": {
"telemetry.enableTelemetry": false,
"redhat.telemetry.enabled": false,
"vulnCost.sendStatistics": false,

"editor.renderWhitespace": "all",
"editor.renderControlCharacters": true,
"editor.formatOnSave": true,

"files.insertFinalNewline": true
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"Orta.vscode-jest",
"GitHub.vscode-pull-request-github",
"GitHub.copilot",
"ms-toolsai.jupyter"
"ms-toolsai.jupyter",
"ms-python.python",
"ms-azuretools.vscode-docker",
"yzhang.markdown-all-in-one"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 3450],
"forwardPorts": [
30000,
3450
],
"portsAttributes": {
"3000": {
"30000": {
"label": "Front End",
"protocol": "http",
"protocol": "https",
"onAutoForward": "openBrowserOnce"
},
"3450": {
"label": "API Server",
"protocol": "http"
"protocol": "https"
}
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pnpm install",

// "postCreateCommand": "pnpm install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
"remoteUser": "node",
"hostRequirements": {
"cpus": 4,
"memory": "8gb",
"storage": "15gb"
},
"customizations": {
"codespaces": {
"openFiles": [
"workshop.cn.ipynb"
]
}
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/docker-from-docker:1": {}
}
}
3 changes: 2 additions & 1 deletion configs/allowed-origins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ private_origins:
- ^http://localhost:\d+$
# Preview.
- ^https://pingcap-ossinsight-preview-pr-.+\.surge\.sh$
- ^https*://.+\.preview\.app\.github\.dev/*$
# Production.
- ^https://ossinsight\.io$
- ^https://live\.ossinsight\.io$
public_origins:
# External Users.
- ^https://github1s\.com$
- ^https://github\.com$
- ^https://github\.com$
29 changes: 8 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '3.9'

# tiup playground v6.1.0 -T oss --without-monitor --db.host 0.0.0.0 --tiflash 1
# tiup playground v6.4.0 -T ossinsight --without-monitor --db.host 0.0.0.0 --tiflash 1

services:
etl:
Expand All @@ -23,11 +23,12 @@ services:
- DATABASE_URL=${ETL_DATABASE_URL:?err}
- GITHUB_TOKEN=${GITHUB_TOKEN:?err}
- SKIP_REPLICA=1
- DB_FORCE_SSL=${DB_FORCE_SSL:-true}

api:
build:
context: ./packages/api-server
dockerfile: ./Dockerfile
context: .
dockerfile: ./packages/api-server/Dockerfile
args:
NODE_ENV: 'development'
image: hooopo/ossinsight-api:latest
Expand All @@ -39,7 +40,6 @@ services:
condition: service_started
environment:
- DATABASE_URL=${API_DATABASE_URL:?err}
- CONFIGS_PATH=${CONFIGS_PATH:-./configs}
- SERVER_PORT=3450
- GITHUB_ACCESS_TOKENS=${GITHUB_TOKEN:?err}
- ENABLE_CACHE=${ENABLE_CACHE:-false}
Expand All @@ -48,29 +48,16 @@ services:
image: hooopo/ossinsight-web:latest
restart: always
build:
context: ./web
dockerfile: ./Dockerfile
context: .
dockerfile: ./web/Dockerfile
args:
NODE_ENV: 'development'
ports:
- "30000:30000"
environment:
- NODE_ENV=development
- APP_HOST=http://localhost:30000
- APP_API_BASE=http://localhost:3450
volumes:
- ./:/app:delegated
- node_modules:/app/node_modules
- prefetch:/app/.prefetch
- docusaurus:/app/.docusaurus
- APP_HOST=${APP_HOST:-http://localhost:30000}
- APP_API_BASE=${APP_API_BASE:-http://localhost:3450}

networks:
default:

volumes:
packs:
node_modules:
cache:
bundle:
prefetch:
docusaurus:
17 changes: 10 additions & 7 deletions packages/api-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Build stage.
FROM node:18-alpine AS builder

WORKDIR /app
WORKDIR /app/packages/api-server

# Install dependencies.
RUN npm install -g pnpm
COPY pnpm-lock.yaml package.json ./
COPY ./packages/api-server/pnpm-lock.yaml ./packages/api-server/package.json ./
RUN pnpm fetch
RUN pnpm install -r --offline

# Copy source code.
COPY tsconfig.json .
COPY src/ ./src
COPY ./packages/api-server/tsconfig.json .
COPY ./packages/api-server/src/ ./src

# Build.
RUN pnpm run build:ts
Expand All @@ -24,10 +24,13 @@ FROM node:18-alpine AS runtime

ENV NODE_ENV=production

WORKDIR /app
WORKDIR /app/packages/api-server

COPY --from=builder /app .
COPY --from=builder /app/packages/api-server .

# Copy the configs dir.
COPY ./configs /app/configs

EXPOSE 3450

CMD ["npm", "run", "start"]
CMD ["npm", "run", "start"]
13 changes: 8 additions & 5 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
FROM node:18-alpine

# Create app directory
WORKDIR /app
WORKDIR /app/web

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied where available (npm@5+)
COPY package*.json ./
COPY plugins ./plugins
COPY *.mjs ./
COPY ./web/package*.json .
COPY ./web/plugins ./plugins
COPY ./web/*.mjs .

RUN npm ci

# Bundle app source
COPY . .
COPY ./web .

# Copy the configs dir.
COPY ./configs /app/configs

EXPOSE 30000

Expand Down
2 changes: 1 addition & 1 deletion web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"baseUrl": ".",
"paths": {
"@query/*": ["../api/queries/*"],
"@query/*": ["../configs/queries/*"],
"@site/*": ["./*"],
"@docusaurus/theme-common/*": ["./node_modules/@docusaurus/theme-common/lib/*"]
}
Expand Down
Loading

0 comments on commit 29237df

Please sign in to comment.