Skip to content

Commit 5d8bd25

Browse files
xrgzsCopilot
andauthored
refactor(docker): reduce docker image size (#1091)
* fix(docker): reduce image size * refactor(docker): update user and group creation * Update Dockerfile Co-authored-by: Copilot <[email protected]> Signed-off-by: MadDogOwner <[email protected]> --------- Signed-off-by: MadDogOwner <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 08c5283 commit 5d8bd25

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ ARG GID=1001
2020

2121
WORKDIR /opt/openlist/
2222

23-
COPY --chmod=755 --from=builder /app/bin/openlist ./
24-
COPY --chmod=755 entrypoint.sh /entrypoint.sh
25-
RUN adduser -u ${UID} -g ${GID} -h /opt/openlist/data -D -s /bin/sh ${USER} \
26-
&& chown -R ${UID}:${GID} /opt \
27-
&& chown -R ${UID}:${GID} /entrypoint.sh
23+
RUN addgroup -g ${GID} ${USER} && \
24+
adduser -D -u ${UID} -G ${USER} ${USER} && \
25+
mkdir -p /opt/openlist/data
26+
27+
COPY --from=builder --chmod=755 --chown=${UID}:${GID} /app/bin/openlist ./
28+
COPY --chmod=755 --chown=${UID}:${GID} entrypoint.sh /entrypoint.sh
2829

2930
USER ${USER}
3031
RUN /entrypoint.sh version

Dockerfile.ci

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ ARG GID=1001
1010

1111
WORKDIR /opt/openlist/
1212

13-
COPY --chmod=755 /build/${TARGETPLATFORM}/openlist ./
14-
COPY --chmod=755 entrypoint.sh /entrypoint.sh
13+
RUN addgroup -g ${GID} ${USER} && \
14+
adduser -D -u ${UID} -G ${USER} ${USER} && \
15+
mkdir -p /opt/openlist/data
1516

16-
RUN adduser -u ${UID} -g ${GID} -h /opt/openlist/data -D -s /bin/sh ${USER} \
17-
&& chown -R ${UID}:${GID} /opt \
18-
&& chown -R ${UID}:${GID} /entrypoint.sh
17+
COPY --chmod=755 --chown=${UID}:${GID} /build/${TARGETPLATFORM}/openlist ./
18+
COPY --chmod=755 --chown=${UID}:${GID} entrypoint.sh /entrypoint.sh
1919

2020
USER ${USER}
2121
RUN /entrypoint.sh version

0 commit comments

Comments
 (0)