From 5441c98841d1581426c48b4d47369c9263cb6a26 Mon Sep 17 00:00:00 2001 From: WJG Date: Thu, 29 Feb 2024 14:29:41 +0800 Subject: [PATCH] fix: Dockerfile --- .dockerignore | 1 + Dockerfile | 9 ++++++--- README.md | 20 +++++++++++++++++++- package.json | 11 +++++------ 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.dockerignore b/.dockerignore index 34eb456..1c3c033 100644 --- a/.dockerignore +++ b/.dockerignore @@ -31,6 +31,7 @@ **/build **/dist LICENSE +TODO.md README.md **/.bot.json **/.mi.json diff --git a/Dockerfile b/Dockerfile index 2dd8a8f..2a9d567 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,8 @@ RUN --mount=type=bind,source=package.json,target=package.json \ # Copy the rest of the source files into the image. COPY . . +# Run the build script. +RUN yarn run build ################################################################################ # Create a new stage to run the application with minimal runtime dependencies @@ -49,9 +51,6 @@ FROM base as final # Use production node environment by default. ENV NODE_ENV production -# Run the application as a non-root user. -USER node - # Copy package.json so that package manager commands can be used. COPY package.json . @@ -59,6 +58,10 @@ COPY package.json . # the built application from the build stage into the image. COPY --from=deps /usr/src/app/node_modules ./node_modules COPY --from=build /usr/src/app/dist ./dist +COPY --from=build /usr/src/app/scripts ./scripts +COPY --from=build /usr/src/app/prisma ./prisma +COPY --from=build /usr/src/app/node_modules/@prisma/client/ ./node_modules/@prisma/client/ +COPY --from=build /usr/src/app/node_modules/.prisma/client/ ./node_modules/.prisma/client/ # Run the application. CMD yarn start diff --git a/README.md b/README.md index d7d5141..cda10ef 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,30 @@ pnpm install mi-gpt import { MiGPT } from "mi-gpt"; async function main() { - // coming soon + const client = MiGPT.create({ + speaker: { + userId: process.env.MI_USER, + password: process.env.MI_PASS, + did: process.env.MI_DID, + }, + }); + await client.start(); } main(); ``` +## 📦 Docker + +Use the following command to start `MiGPT` within a Docker container. + +```shell +# Ensure you have your `.env` file and `.migpt.js` configuration file ready for deployment. +docker run -d --env-file $(pwd)/.env \ + -v $(pwd)/.migpt.js:/usr/src/app/.migpt.js \ + idootop/mi-gpt:1.0.0 +``` + ## 🌈 Embrace the future Welcome to the era of intuitive living with MiGPT, where every command is a conversation, and every interaction is an opportunity for your home to become more in sync with you. Imagine a space that not only listens but also comprehends and evolves—a living space that's as dynamic and intelligent as the world around you. This is not just smart home technology; this is MiGPT, the heartbeat of your AI-driven home, where the future of home automation isn't just arriving, it's already here, ready to transform your daily living into an experience of effortless intelligence. diff --git a/package.json b/package.json index 84a2511..b47686e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mi-gpt", - "version": "1.3.0", + "version": "1.0.0", "type": "module", "description": "Seamlessly integrate your XiaoAI speaker and Mi Home devices with ChatGPT for an enhanced smart home experience.", "license": "MIT", @@ -19,11 +19,10 @@ "home-assistant" ], "scripts": { - "build": "tsup", - "db:gen": "npx prisma migrate dev --name init", - "db:reset": "rm .bot.json && npx prisma migrate reset", - "prepublish": "npm run db:gen && npm run build", - "start": "node ./scripts/runner.js" + "build": "yarn prisma generate && tsup", + "start": "node ./scripts/runner.js", + "db:gen": "yarn prisma migrate dev --name init", + "db:reset": "rm -f .mi.json .bot.json prisma/app.db prisma/app.db-journal" }, "dependencies": { "@prisma/client": "^5.8.1",