From 47e8db3fd79e6ecfc168954016333dc02ccf43c5 Mon Sep 17 00:00:00 2001 From: weaigc <879821485@qq.com> Date: Wed, 29 Nov 2023 00:10:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dcodesandbox=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E9=97=B4=E8=BF=87=E9=95=BF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .codesandbox/tasks.json | 30 +++++++++++++++--------------- .devcontainer/Dockerfile | 32 ++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 30 +++++++++++++++++------------- .github/pull.yml | 5 +++++ Dockerfile | 7 ++++--- package-lock.json | 4 ++-- package.json | 2 +- 7 files changed, 76 insertions(+), 34 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .github/pull.yml diff --git a/.codesandbox/tasks.json b/.codesandbox/tasks.json index 9a3d6bf3..3b6a2ac5 100644 --- a/.codesandbox/tasks.json +++ b/.codesandbox/tasks.json @@ -1,45 +1,45 @@ { // These tasks will run in order when initializing your CodeSandbox project. - "setupTasks": [ - { - "name": "Install Dependencies", - "command": "npm install" - } - ], + "setupTasks": [], // These tasks can be run from CodeSandbox. Running one will open a log in the app. "tasks": { "dev": { "name": "Start Server", - "command": "npm install && npm run build && npm start", + "command": "npm i && npm run dev", "runAtStart": true, "preview": { "port": 3000 }, "restartOn": { - "files": ["./package-lock.json"] + "files": [ + "./package.json" + ], + "branch": false, + "resume": false } }, "build": { "name": "Build", - "command": "npm run build", - "runAtStart": false + "command": "npm run build" }, "start": { "name": "Start Server", - "command": "npm run start", - "runAtStart": false + "command": "npm i && npm run build && npm start", }, "lint": { "name": "Lint", - "command": "npm run lint", - "runAtStart": false + "command": "npm run lint" }, "install": { "name": "Install Dependencies", "command": "npm install", "restartOn": { - "files": ["./package.json"] + "files": [ + "./package.json" + ], + "branch": false, + "resume": false } } } diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..018e25be --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,32 @@ +FROM weaigc/bingo as build + +FROM mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye + +ARG DEBIAN_FRONTEND=noninteractive + +# 如果没有特别需要不要配置 +ENV BING_HEADER "" + +# Set home to the user's home directory +ENV HOME=/home/user \ + PATH=/home/user/.local/bin:$PATH + +# Set up a new user named "user" with user ID 1000 +RUN useradd -o -u 1000 user && mkdir -p $HOME/app && chown -R user $HOME + +# Switch to the "user" user +USER user + +# Set the working directory to the user's home directory +WORKDIR $HOME/app + +# Copy the current directory contents into the container at $HOME/app setting the owner to the user +COPY --chown=user . $HOME/app/ + +COPY --from=build /home/user/app $HOME/ + +ENV PORT 7860 + +EXPOSE 7860 + +# CMD npm start diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 19f7f683..0e23190a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,22 +1,26 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node { - "name": "Node.js & TypeScript", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye" + "name": "Node.js & TypeScript", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "build": { + // Path is relative to the devcontainer.json file. + "dockerfile": "Dockerfile", + "context": ".." + } - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "yarn install", + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", - // Configure tool-specific properties. - // "customizations": {}, + // Configure tool-specific properties. + // "customizations": {}, - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" } diff --git a/.github/pull.yml b/.github/pull.yml new file mode 100644 index 00000000..270aefb0 --- /dev/null +++ b/.github/pull.yml @@ -0,0 +1,5 @@ +version: "1" +rules: + - base: main + upstream: weaigc:main # change `weaigc` to the owner of upstream repo + mergeMethod: rebase diff --git a/Dockerfile b/Dockerfile index ace0ce3d..983b70d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,13 @@ -FROM node:18 +FROM node:20 ARG DEBIAN_FRONTEND=noninteractive +# 如果没有特别需要不要配置 ENV BING_HEADER "" # Set home to the user's home directory ENV HOME=/home/user \ - PATH=/home/user/.local/bin:$PATH + PATH=/home/user/.local/bin:$PATH # Set up a new user named "user" with user ID 1000 RUN useradd -o -u 1000 user && mkdir -p $HOME/app && chown -R user $HOME @@ -22,7 +23,7 @@ COPY --chown=user . $HOME/app/ RUN if [ ! -f ".next/routes-manifest.json" ]; then \ npm install && npm run build; \ -fi + fi RUN rm -rf src diff --git a/package-lock.json b/package-lock.json index e9c94956..caac2ed0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bingo", - "version": "1.3.0", + "version": "1.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bingo", - "version": "1.3.0", + "version": "1.4.0", "dependencies": { "@headlessui/react": "^1.7.17", "@radix-ui/react-alert-dialog": "^1.0.4", diff --git a/package.json b/package.json index 18e78d09..1e4af3bb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "cross-env DEBUG=bingo* NODE_ENV=development node ./server.js", "build": "next build", "proxy": "node ./cloudflare/cli.js", - "start": "cross-env NODE_ENV=production node ./server.js", + "start": "node ./scripts/pre-check.js && cross-env NODE_ENV=production node ./server.js", "lint": "next lint" }, "dependencies": {