Skip to content

Commit fffb8f5

Browse files
committed
增加docker
1 parent 574cd50 commit fffb8f5

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM node:14-alpine3.13
2+
3+
# 项目地址(国内加速)
4+
ARG gitUrl="https://ghproxy.com/https://github.com/nn200433/node-metaweblog-api-adaptor.git"
5+
6+
# 定义环境变量
7+
ENV TZ=Asia/Shanghai
8+
9+
# 安装一些常用组件
10+
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
11+
apk add -U --no-cache \
12+
sudo \
13+
g++ \
14+
gcc \
15+
libev-dev \
16+
libevent-dev \
17+
libuv-dev \
18+
make \
19+
ca-certificates \
20+
bash \
21+
curl \
22+
git \
23+
openssh \
24+
openssl-dev \
25+
alpine-sdk \
26+
python3 py3-pip \
27+
tzdata && \
28+
cp /usr/share/zoneinfo/${TZ} /etc/localtime && \
29+
echo ${TZ} > /etc/timezone && \
30+
apk del tzdata && \
31+
mkdir -p /home
32+
33+
# 下载项目
34+
RUN cd /home && \
35+
git clone --depth=1 "${gitUrl}" metaweblog-api
36+
37+
# 编译项目
38+
RUN cd /home/metaweblog-api && \
39+
npm config set unsafe-perm true && \
40+
npm config set registry https://registry.npm.taobao.org && \
41+
yarn config set registry http://registry.npm.taobao.org && \
42+
npm install -g pnpm && \
43+
yarn install
44+
45+
# 指定默认工作目录
46+
WORKDIR /home/metaweblog-api
47+
48+
# 默认3000端口
49+
EXPOSE 3000/tcp
50+
51+
ENTRYPOINT ["/home/metaweblog-api/entrypoint.sh"]

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: '3'
2+
services:
3+
metaweblog-api:
4+
image: nn200433/metaweblog-api:latest
5+
container_name: metaweblog-api
6+
restart: unless-stopped
7+
ports:
8+
- 6333:3000
9+
environment:
10+
- TZ=Asia/Shanghai

entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
# 启动
4+
exec yarn dev

0 commit comments

Comments
 (0)