Skip to content

Commit

Permalink
Fix docker build (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored Dec 21, 2024
1 parent f653735 commit 223e1c8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

ARG NODE_VERSION=22

FROM --platform=$TARGETPLATFORM node:${NODE_VERSION}-slim AS builder

WORKDIR /app
COPY . ./
RUN corepack enable \
&& pnpm i --frozen-lockfile --aggregate-output \
&& NODE_ENV=production pnpm run build

FROM --platform=$TARGETPLATFORM node:${NODE_VERSION}-slim

ARG UID="991"
Expand All @@ -12,22 +20,23 @@ RUN apt-get update \
libjemalloc-dev libjemalloc2 \
&& ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so \
&& corepack enable \
&& groupadd -g "${GID}" proxy \
&& useradd -l -u "${UID}" -g "${GID}" -m -d /app proxy \
&& groupadd -g "${GID}" media-proxy \
&& useradd -l -u "${UID}" -g "${GID}" -m -d /app media-proxy \
&& find / -type d -path /sys -prune -o -type d -path /proc -prune -o -type f -perm /u+s -ignore_readdir_race -exec chmod u-s {} \; \
&& find / -type d -path /sys -prune -o -type d -path /proc -prune -o -type f -perm /g+s -ignore_readdir_race -exec chmod g-s {} \; \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists

USER proxy
USER media-proxy
WORKDIR /app
COPY --chown=proxy:proxy . ./
COPY --chown=media-proxy:media-proxy . ./
COPY --from=builder --chown=media-proxy:media-proxy /app/built ./built
COPY --from=builder --chown=media-proxy:media-proxy /app/server.js ./

ENV NODE_ENV=production

RUN corepack install \
&& pnpm i --frozen-lockfile --aggregate-output \
&& pnpm run build \
&& corepack pack

ENV COREPACK_ENABLE_NETWORK=0
Expand Down

0 comments on commit 223e1c8

Please sign in to comment.