From b9bbc0446b03e2146842190e5855685bb12b99c6 Mon Sep 17 00:00:00 2001 From: LK HO Date: Sun, 5 Nov 2023 01:49:28 +0800 Subject: [PATCH] feat: docker image (#68) --- .dockerignore | 1 + Dockerfile | 13 +++++++++++++ README.md | 30 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..c2658d7d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..6237657b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:lts AS builder + +WORKDIR /app +COPY . . +RUN corepack enable +RUN pnpm install --frozen-lockfile --strict-peer-dependencies +RUN pnpm run build + +# the final image, only need to serve the static files +FROM nginx:alpine + +RUN apk update && apk upgrade +COPY --from=builder /app/build /usr/share/nginx/html diff --git a/README.md b/README.md index 8957ac1d..4879ff1f 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,21 @@ npm start npm run dev-server ``` +## Deployment in Production + +After building (`npm run build`), the `build` folder is the static website files. +You can deploy it to any CDN or static file server. + +You can also build a docker image using the `Dockerfile` at the root of this repo. +It runs the build and give you a minimal nginx image. + +```bash +# build image +docker build -t lrc-maker . +# create a container and serve at port 8080 +docker run -d -p 8080:80 lrc-maker +``` + ## Star this project :star: If you like give us a star :star: Share this project to help more people. @@ -171,6 +186,21 @@ npm start npm run dev-server ``` +## 生产部署 + +构建(`npm run build`)后,`build` 文件夹是静态网站文件。 +您可以将其部署到任何 CDN 或静态文件服务器。 + +您还可以使用此存储库根目录下的 `Dockerfile` 构建一个 docker 镜像。 +它运行构建并创建最小化的 nginx 镜像。 + +```bash +# 构建 +docker build -t lrc-maker . +# 创建一个容器并在 8080 端口提供服务 +docker run -d -p 8080:80 lrc-maker +``` + ## 给这个项目点一个星星 :star: 如果你喜欢这个项目,请点一个星星吧:star:,分享这个项目来帮助更多的人。