diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..06e222c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +FROM node:14-alpine3.13 + +# 项目地址(国内加速) +ARG gitUrl="https://ghproxy.com/https://github.com/nn200433/node-metaweblog-api-adaptor.git" + +# 定义环境变量 +ENV TZ=Asia/Shanghai + +# 安装一些常用组件 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \ + apk add -U --no-cache \ + sudo \ + g++ \ + gcc \ + libev-dev \ + libevent-dev \ + libuv-dev \ + make \ + ca-certificates \ + bash \ + curl \ + git \ + openssh \ + openssl-dev \ + alpine-sdk \ + python3 py3-pip \ + tzdata && \ + cp /usr/share/zoneinfo/${TZ} /etc/localtime && \ + echo ${TZ} > /etc/timezone && \ + apk del tzdata && \ + mkdir -p /home + +# 下载项目 +RUN cd /home && \ + git clone --depth=1 "${gitUrl}" metaweblog-api && \ + cd metaweblog-api && chmod +x entrypoint.sh + +# 编译项目 +RUN cd /home/metaweblog-api && \ + npm config set unsafe-perm true && \ + npm config set registry https://registry.npm.taobao.org && \ + yarn config set registry http://registry.npm.taobao.org && \ + npm install -g pnpm && \ + yarn install + +# 指定默认工作目录 +WORKDIR /home/metaweblog-api + +# 默认3000端口 +EXPOSE 3000/tcp + +ENTRYPOINT ["/home/metaweblog-api/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 616db48..9b18b7b 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,29 @@ The `pages/api` directory is mapped to `/api/*`. Files in this directory are tre This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. +## Docker + +docker: + +```bash +docker run -itd --name=metaweblog-api -p 6333:3000 -e TZ=Asia/Shanghai --restart=unless-stopped nn200433/metaweblog-api:latest +``` + +docker-compose: + +```yaml +version: '3' +services: + metaweblog-api: + image: nn200433/metaweblog-api:latest + container_name: metaweblog-api + restart: unless-stopped + ports: + - 6333:3000 + environment: + - TZ=Asia/Shanghai +``` + ## Learn More To learn more about Next.js, take a look at the following resources: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0dcf052 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' +services: + metaweblog-api: + image: nn200433/metaweblog-api:latest + container_name: metaweblog-api + restart: unless-stopped + ports: + - 6333:3000 + environment: + - TZ=Asia/Shanghai \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..ac29d0f --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# 启动 +exec yarn dev \ No newline at end of file