Skip to content

Commit

Permalink
feat: dokcer image support PUID PGID
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Oct 10, 2024
1 parent 485a580 commit c522046
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 9 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

## 重设权限
chown -R "${PUID}:${PGID}" /app/data

umask ${UMASK:-022}

cd /app
exec gosu "${PUID}:${PGID}" /app/polaris

0 comments on commit c522046

Please sign in to comment.