Skip to content

Commit 315615c

Browse files
committed
chore: docker permissions
1 parent 139b969 commit 315615c

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

docker/docker-compose.dev.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ services:
3535
- /etc/localtime:/etc/localtime:ro
3636
env_file:
3737
- .env
38+
user: ${S_UID:-0}:${S_GID:-0}
3839
environment:
3940
IMMICH_REPOSITORY: immich-app/immich
4041
IMMICH_REPOSITORY_URL: https://github.com/immich-app/immich
@@ -66,8 +67,8 @@ services:
6667
immich-web:
6768
container_name: immich_web
6869
image: immich-web-dev:latest
69-
# Needed for rootless docker setup, see https://github.com/moby/moby/issues/45919
70-
# user: 0:0
70+
# user: 0:0 needed for rootless docker setup, see https://github.com/moby/moby/issues/45919
71+
user: ${W_UID:-1000}:${W_GID:-1000}
7172
build:
7273
context: ../
7374
dockerfile: web/Dockerfile

server/Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ RUN apt-get update && apt-get install --no-install-recommends -yqq tini make
66
WORKDIR /usr/src/app
77
COPY ./server/package* ./server/
88
WORKDIR /usr/src/app/server
9-
RUN npm ci && \
9+
RUN echo "umask 000" >> /etc/profile && \
10+
echo "umask 000" >> /etc/bash.bashrc && \
11+
umask 000 && \
12+
chmod o+wx /usr/src/app && \
13+
chmod o+wx /usr/src/app/server && \
14+
npm ci && \
1015
# exiftool-vendored.pl, sharp-linux-x64 and sharp-linux-arm64 are the only ones we need
1116
# they're marked as optional dependencies, so we need to copy them manually after pruning
1217
rm -rf node_modules/@img/sharp-libvips* && \
@@ -28,17 +33,14 @@ RUN apt-get update && \
2833
RUN usermod -aG sudo node
2934
RUN echo "node ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
3035
RUN mkdir -p /workspaces/immich
31-
RUN chown node -R /workspaces
32-
COPY --chown=node:node --chmod=777 ../.devcontainer/server/*.sh /immich-devcontainer/
36+
COPY --chmod=777 ../.devcontainer/server/*.sh /immich-devcontainer/
3337

34-
USER node
35-
COPY --chown=node:node .. /tmp/create-dep-cache/
38+
COPY .. /tmp/create-dep-cache/
3639
WORKDIR /tmp/create-dep-cache
3740
RUN make ci-all && rm -rf /tmp/create-dep-cache
3841

39-
4042
FROM dev-container-server AS dev-container-mobile
41-
USER root
43+
4244
# Enable multiarch for arm64 if necessary
4345
RUN if [ "$(dpkg --print-architecture)" = "arm64" ]; then \
4446
dpkg --add-architecture amd64 && \
@@ -64,7 +66,6 @@ RUN mkdir -p ${FLUTTER_HOME} \
6466
&& rm flutter.tar.xz \
6567
&& chown -R node ${FLUTTER_HOME}
6668

67-
USER node
6869
RUN sudo apt-get update \
6970
&& wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg \
7071
&& echo 'deb [signed-by=/usr/share/keyrings/dcm.gpg arch=amd64] https://dcm.dev/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list \

web/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ COPY --chown=node:node ./open-api ./open-api/
99
COPY --chown=node:node Makefile ./
1010

1111
WORKDIR /usr/src/app/web
12-
RUN npm ci
12+
RUN umask 000 && \
13+
find /usr/src/app -type d -exec chmod o+rwx {} \; && \
14+
find /usr/src/app -type f -exec chmod o+rw {} \; && \
15+
npm ci
1316

1417
ENV CHOKIDAR_USEPOLLING=true
1518
EXPOSE 24678

0 commit comments

Comments
 (0)