Jeremy Zheng 4 лет назад
Родитель
Сommit
41b527db9b

+ 13 - 2
dashboard/.editorconfig

@@ -1,9 +1,20 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
 # dependencies
-/node_modules/
+/node_modules
+/npm-debug.log*
+/yarn-error.log
 /yarn.lock
+/package-lock.json
 
 # production
-/dist/
+/dist
+
+# misc
+.DS_Store
 
 # umi
 /src/.umi
+/src/.umi-production
+/src/.umi-test
+/.env.local

+ 1 - 0
dashboard/.umirc.ts

@@ -7,4 +7,5 @@ export default defineConfig({
   routes: [
     { path: '/', component: '@/pages/index' },
   ],
+  fastRefresh: {},
 });

+ 40 - 0
dashboard/README.md

@@ -0,0 +1,40 @@
+# Usage
+
+```bash
+# install dependencies
+yarn install
+# start the dev server
+yarn start
+```
+
+## Getting Started in **7** days
+
+### Day 1: Prepare
+
+- [TypeScript for JavaScript Programmers](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html)
+- [Install ubuntu@wls(ONLY For Windows User)](https://ubuntu.com/wsl)
+- [Start continer](../docker)
+- How to use tmux
+  
+  ```text
+  Ctrl+b %
+  Ctrl+b "
+  Ctrl+b up
+  Ctrl+b down
+  Ctrl+b left
+  Ctrl+b right
+  ```
+
+- Start backend & frontend server
+
+### Day 2
+
+### Day 3
+
+### Day 4
+
+### Day 5
+
+### Day 6
+
+### Day 7

+ 11 - 5
dashboard/package.json

@@ -20,13 +20,19 @@
     ]
   },
   "dependencies": {
+    "@ant-design/pro-layout": "^6.5.0",
     "@umijs/preset-react": "1.x",
-    "@umijs/test": "^3.2.3",
+    "umi": "^3.4.25"
+  },
+  "devDependencies": {
+    "@types/react": "^17.0.0",
+    "@types/react-dom": "^17.0.0",
+    "@umijs/test": "^3.4.25",
     "lint-staged": "^10.0.7",
-    "prettier": "^1.19.1",
-    "react": "^16.12.0",
-    "react-dom": "^16.12.0",
-    "umi": "^3.2.3",
+    "prettier": "^2.2.0",
+    "react": "17.x",
+    "react-dom": "17.x",
+    "typescript": "^4.1.2",
     "yorkie": "^2.0.0"
   }
 }

+ 0 - 4
dashboard/src/pages/index.less

@@ -1,7 +1,3 @@
-
-.normal {
-}
-
 .title {
   background: rgb(121, 242, 157);
 }

+ 1 - 2
dashboard/src/pages/index.tsx

@@ -1,7 +1,6 @@
-import React from 'react';
 import styles from './index.less';
 
-export default () => {
+export default function IndexPage() {
   return (
     <div>
       <h1 className={styles.title}>Page index</h1>

+ 12 - 1
dashboard/tsconfig.json

@@ -4,7 +4,7 @@
     "module": "esnext",
     "moduleResolution": "node",
     "importHelpers": true,
-    "jsx": "react",
+    "jsx": "react-jsx",
     "esModuleInterop": true,
     "sourceMap": true,
     "baseUrl": "./",
@@ -21,5 +21,16 @@
     "config/**/*",
     ".umirc.ts",
     "typings.d.ts"
+  ],
+  "exclude": [
+    "node_modules",
+    "lib",
+    "es",
+    "dist",
+    "typings",
+    "**/__test__",
+    "test",
+    "docs",
+    "tests"
   ]
 }

+ 6 - 4
dashboard/typings.d.ts

@@ -1,8 +1,10 @@
 declare module '*.css';
 declare module '*.less';
-declare module "*.png";
+declare module '*.png';
 declare module '*.svg' {
-  export function ReactComponent(props: React.SVGProps<SVGSVGElement>): React.ReactElement
-  const url: string
-  export default url
+  export function ReactComponent(
+    props: React.SVGProps<SVGSVGElement>,
+  ): React.ReactElement;
+  const url: string;
+  export default url;
 }

+ 1 - 0
docker/.gitignore

@@ -0,0 +1 @@
+*.tar

+ 59 - 0
docker/Dockerfile

@@ -0,0 +1,59 @@
+FROM ubuntu:latest
+LABEL maintainer="Jeremy Zheng"
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt update
+RUN apt -y upgrade
+RUN apt -y install apt-transport-https software-properties-common curl wget gnupg
+
+RUN apt -y install zsh git locales rsync openssh-client sshpass \
+    vim sudo tzdata pwgen curl zip unzip tree screen tmux \
+    build-essential \
+    php-cli php-fpm \
+    php-xml php-json php-imap php-intl \
+    php-mbstring php-bz2 php-zip php-curl \
+    php-gd php-imagick \
+    php-mysql php-pgsql php-sqlite3 php-redis
+RUN apt -y autoremove
+RUN apt -y clean
+
+RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
+RUN locale-gen
+RUN update-locale LANG=en_US.UTF-8
+RUN update-alternatives --set editor /usr/bin/vim.basic
+
+# deploy
+RUN useradd -m deploy -s /bin/zsh
+RUN passwd -l deploy
+RUN echo 'deploy ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/101-deploy
+
+USER deploy
+
+RUN mkdir -p $HOME/downloads $HOME/local
+
+# https://github.com/ohmyzsh/ohmyzsh
+RUN git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
+RUN cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
+RUN echo 'source $HOME/.profile' >> $HOME/.zshrc
+
+RUN echo 'term screen-256color' >> $HOME/.screenrc
+RUN echo 'startup_message off' >> $HOME/.screenrc
+RUN echo "defscrollback 10240" >> $HOME/.screenrc
+
+# https://github.com/nvm-sh/nvm
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | sh
+RUN sh -c ". $HOME/.profile \
+    && nvm install node"
+RUN sh -c ". $HOME/.profile \
+    && npm i yarn -g"
+RUN echo 'export PATH=$HOME/.yarn/bin:$PATH' >> $HOME/.profile
+
+RUN mkdir -p $HOME/.local/bin
+RUN wget https://getcomposer.org/download/latest-stable/composer.phar -O $HOME/.local/bin/composer
+RUN chmod +x $HOME/.local/bin/composer
+
+VOLUME /workspace
+WORKDIR /workspace
+
+CMD ["/bin/zsh", "-l"]

+ 21 - 0
docker/README.md

@@ -0,0 +1,21 @@
+# Usage for Ubuntu 20.10 and newer
+
+## Podman
+
+- Install
+
+```bash
+sudo apt -y install podman runc buildah skopeo
+```
+
+- Setup `/etc/containers/registries.conf`
+
+```text
+[registries.search]
+registries = ['quay.io', 'docker.io']
+```
+
+- Build(`cd docker && sh build.sh`) **OR** Import(`podman load -q -i mint-TIMESTAMP.tar`) image
+- Enjoy it!
+
+  ![start](documents/start.png)

+ 14 - 0
docker/build.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+export VERSION=$(date "+%4Y%m%d%H%M%S")
+export CODE="mint"
+
+buildah pull ubuntu:latest
+buildah bud --layers -t $CODE .
+podman save -o $CODE-$VERSION.tar $CODE
+
+echo 'done.'
+
+exit 0

+ 5 - 0
docker/start.sh

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+podman run --rm -it --userns=keep-id \
+    --user=$(id -ur):$(id -gr) --network host \
+    --events-backend=file -v $PWD:/workspace:z mint