mirror of
https://github.com/actualbudget/actual.git
synced 2026-07-12 13:17:23 -05:00
55 lines
1.8 KiB
Docker
55 lines
1.8 KiB
Docker
FROM node:22-bookworm AS builder
|
|
|
|
# Install required packages
|
|
RUN apt-get update && apt-get install -y openssl
|
|
|
|
WORKDIR /app
|
|
|
|
COPY .yarn ./.yarn
|
|
COPY yarn.lock package.json .yarnrc.yml ./
|
|
COPY packages ./packages
|
|
|
|
# Avoiding memory issues with ARMv7
|
|
RUN if [ "$(uname -m)" = "armv7l" ]; then yarn config set taskPoolConcurrency 2; yarn config set networkConcurrency 5; fi
|
|
|
|
# Focus the workspaces in production mode
|
|
RUN yarn workspaces focus @actual-app/sync-server --production
|
|
|
|
# Dereference yarn's workspace:* symlinks so the prod stage can copy just node_modules.
|
|
RUN cp -RL node_modules node_modules.real \
|
|
&& rm -rf node_modules \
|
|
&& mv node_modules.real node_modules
|
|
|
|
# Strip dev-only content from dereferenced workspace packages to keep the final image lean.
|
|
RUN find node_modules/@actual-app -maxdepth 2 -type d \
|
|
\( -name src -o -name e2e -o -name __tests__ -o -name __mocks__ -o -name tests -o -name test -o -name build-stats \) \
|
|
-exec rm -rf {} +
|
|
|
|
FROM node:22-bookworm-slim AS prod
|
|
|
|
# Minimal runtime dependencies
|
|
RUN apt-get update && apt-get install tini && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create a non-root user
|
|
ARG USERNAME=actual
|
|
ARG USER_UID=1001
|
|
ARG USER_GID=$USER_UID
|
|
RUN groupadd --gid $USER_GID $USERNAME \
|
|
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
|
|
&& mkdir /data && chown -R ${USERNAME}:${USERNAME} /data
|
|
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
|
|
# sync-server entry flattened at /app so CMD stays `node app.js`.
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/packages/sync-server/package.json ./
|
|
COPY --from=builder /app/packages/sync-server/build ./
|
|
|
|
# script dir changed when we swapped build method, add the legacy dir in for compatibility
|
|
RUN mkdir -p src && ln -s ../scripts src/scripts
|
|
|
|
ENTRYPOINT ["/usr/bin/tini","-g", "--"]
|
|
EXPOSE 5006
|
|
CMD ["node", "app.js"]
|