Skip to content

Commit

Permalink
Merge pull request #112 from DDS-Derek/master
Browse files Browse the repository at this point in the history
Add PUID, PGID, Umask settings to Docker image
  • Loading branch information
likun7981 authored Dec 30, 2022
2 parents 0c0768f + a513b32 commit cafbb2b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
21 changes: 18 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
FROM node:lts-alpine

LABEL MAINTAINER likun7981
RUN npm i -g hlink

ENV DOCKER=true \
PS1="\u@\h:\w \$ " \
PUID=1000 \
PGID=1000 \
UMASK=022

RUN apk add --no-cache \
bash \
su-exec \
&& \
npm i -g hlink

COPY --chmod=755 entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]

EXPOSE 9090
ENV DOCKER true
ENTRYPOINT hlink start
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

if [[ -n "${HLINK_HOME}" ]]; then
if [[ "$(stat -c '%u' ${HLINK_HOME})" != "${PUID}" ]] || [[ "$(stat -c '%g' ${HLINK_HOME})" != "${PGID}" ]]; then
chown ${PUID}:${PGID} \
${HLINK_HOME}
fi
fi

umask ${UMASK}

su-exec ${PUID}:${PGID} hlink start
8 changes: 7 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
## 使用docker run
```bash
docker run -d --name hlink \
-e PUID=$YOUR_USER_ID \
-e PGID=$YOUR_GROUP_ID \
-e UMASK=$YOUR_UMASK \
-e HLINK_HOME=$YOUR_HLINK_HOME_DIR \
-p 9090:9090 \
-v $YOUR_NAS_VOLUME_PATH:$DOCKER_VOLUME_PATH \
Expand All @@ -47,10 +50,13 @@ services:
volumes: # 这个表示存储空间映射
- $YOUR_NAS_VOLUME_PATH:$DOCKER_VOLUME_PATH
environment:
- PUID=$YOUR_USER_ID
- PGID=$YOUR_GROUP_ID
- UMASK=$YOUR_UMASK
- HLINK_HOME=$YOUR_HLINK_HOME_DIR # 这个是环境变量
```
`$YOUR_HLINK_HOME_DIR`、`$YOUR_NAS_VOLUME_PATH`、`$DOCKER_VOLUME_PATH`为变量,根据自己的情况自行设置
`$YOUR_USER_ID`、`$YOUR_GROUP_ID`、`$YOUR_UMASK`、`$YOUR_HLINK_HOME_DIR`、`$YOUR_NAS_VOLUME_PATH`、`$DOCKER_VOLUME_PATH`为变量,根据自己的情况自行设置


## 使用npm安装
Expand Down

1 comment on commit cafbb2b

@vercel
Copy link

@vercel vercel bot commented on cafbb2b Dec 30, 2022

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.