Skip to content

Commit

Permalink
Merge pull request #13 from nn200433/main
Browse files Browse the repository at this point in the history
增加docker部署方式
  • Loading branch information
terwer committed Jan 29, 2023
2 parents 574cd50 + 433e4f7 commit 00441b8
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# 启动
exec yarn dev

1 comment on commit 00441b8

@vercel
Copy link

@vercel vercel bot commented on 00441b8 Jan 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.