Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM node:alpine3.17

# 项目地址(国内加速)
ARG gitUrl="https://ghproxy.com/https://github.com/nn200433/snapdrop.git"

# 定义环境变量
ENV TZ=Asia/Shanghai
ENV PORT=3000
ENV OPTIONS=

# 安装一些常用组件
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
apk add -U --no-cache \
ca-certificates \
bash \
curl \
git \
openssh \
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}" && \
cd snapdrop && chmod +x entrypoint.sh

# 编译项目
RUN cd /home/snapdrop && \
npm config set registry https://registry.npm.taobao.org && \
# npm install -g pm2 && \
npm install

# 指定默认工作目录
WORKDIR /home/snapdrop

# 默认3000端口
EXPOSE 3000/tcp

ENTRYPOINT ["/home/snapdrop/entrypoint.sh"]
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,29 @@ Make sure to check your ip address using your OS command.
By default, it is used inside the LAN.\
Users who are not in the same LAN can establish a connection by entering the same room name.\
Enter a blank room name to return to LAN mode.

## How to use Docker

docker:

```bash
docker run -itd --name=snapdrop --net=host --restart=unless-stopped -e PORT=5000 -e OPTIONS=public nn200433/snapdrop:latest
```

docker-compose:

```yml
version: '3'
services:
snapdrop:
image: nn200433/snapdrop:latest
container_name: snapdrop
restart: unless-stopped
network_mode: host
environment:
# 默认3000
- PORT=5000
- TZ=Asia/Shanghai
# 默认内网
- OPTIONS=public
```
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:
snapdrop:
image: nn200433/snapdrop:1.0
container_name: snapdrop
restart: unless-stopped
network_mode: host
environment:
- TZ=Asia/Shanghai
- OPTIONS=public
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# 启动传送
if [ -n "${OPTIONS}" ]; then
echo "即将启动传送..."
echo "参数:OPTIONS = ${OPTIONS}"
#exec pm2 start index.js -- ${OPTIONS}
exec node index.js -- ${OPTIONS}
else
echo "即将启动传送..."
#exec pm2 start index.js
node index.js
fi