feat: dokcer image support PUID PGID

This commit is contained in:
Simon Ding
2024-10-10 16:47:13 +08:00
parent 485a580661
commit c52204619d
2 changed files with 15 additions and 5 deletions

View File

@@ -25,16 +25,17 @@ COPY --from=flutter /app/build/web ./ui/build/web/
RUN CGO_ENABLED=1 go build -o polaris -ldflags="-X polaris/db.Version=$(git describe --tags --long)" ./cmd/
FROM debian:stable-slim
ENV TZ="Asia/Shanghai" GIN_MODE=release
ENV TZ="Asia/Shanghai" GIN_MODE=release PUID=0 PGID=0 UMASK=0 PERMS=true
WORKDIR /app
RUN apt-get update && apt-get -y install ca-certificates
RUN apt-get update && apt-get -y install ca-certificates tzdata gosu tini && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo "${TZ}" > /etc/timezone && apt-get clean
# 将上一个阶段publish文件夹下的所有文件复制进来
COPY --from=builder /app/polaris .
COPY --from=builder /app/entrypoint.sh .
VOLUME /app/data
EXPOSE 8080
#USER 1000:1000
ENTRYPOINT ["./polaris"]
ENTRYPOINT ["tini","./entrypoint.sh"]

9
entrypoint.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
## 重设权限
chown -R "${PUID}:${PGID}" /app/data
umask ${UMASK:-022}
cd /app
exec gosu "${PUID}:${PGID}" /app/polaris