Browse Source

feat: Docker support

master
OhYee 1 year ago
parent
commit
8b61dd125a
Signed by: OhYee
GPG Key ID: 5A9E1F63ED274FBB
  1. 2
      .ohyee/action.bash
  2. 9
      Dockerfile
  3. 31
      build.bash
  4. 5
      utils/request.ts

2
.ohyee/action.bash

@ -41,7 +41,7 @@ else @@ -41,7 +41,7 @@ else
yarn &>>$LOG_FILE
screen -S ${SCREEN_NAME} -X quit &>>$LOG_FILE
screen -wipe &>>$LOG_FILE
screen -dmS ${SCREEN_NAME} 'yarn start 1>>front.log 2>>front.err' &>>$LOG_FILE
screen -dmS ${SCREEN_NAME} bash -c 'yarn start 1>>front.log 2>>front.err' &>>$LOG_FILE
func_log "rebuild at $(date -u '+%Y-%m-%d %H:%M:%S')"
fi

9
Dockerfile

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
FROM node:15.14.0
ENV backendURI="http://backend:50000"
COPY . /data/blotter_page
WORKDIR /data/blotter_page
ENTRYPOINT [ "yarn", "start"]

31
build.bash

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
#!/bin/bash
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
IMAGE="node:15.14.0"
# 拉取镜像
if [[ $(docker images ${IMAGE} | wc -l) -eq "1" ]]; then
echo "Pulling docker image ${IMAGE}..."
docker pull ${IMAGE}
fi
# 更新代码
echo "Pulling latest code..."
git pull
# 在 docker 中挂载当前目录编译
echo "Building execute in docker..."
docker run --rm \
-v ${SHELL_FOLDER}:/data/blotter_page \
${IMAGE} \
bash -c "cd /data/blotter_page && echo 'Generating...' && yarn && yarn build"
echo "Build finished"
docker build -t blotter_page .
echo "Docker image 'blotter' build finished."
echo 'Using `docker run --rm --name=frontend --link backend:backend blotter_page` to start server.'

5
utils/request.ts

@ -1,10 +1,13 @@ @@ -1,10 +1,13 @@
import { message } from '@/components/notification';
import axios from 'axios';
import { env } from 'process';
const backendURI = !!process.env["backendURI"] ? process.env["backendURI"]: 'http://127.0.0.1:50000'
function parseURL(url: string): string {
return (url.length > 0 && url[0] !== '/') || typeof document !== 'undefined'
? url
: 'http://127.0.0.1:50000' + url;
: backendURI + url;
}
// export const requestAsync = async (method: 'post' | 'get', url: string, data: any) => {

Loading…
Cancel
Save