Files
actual/packages/sync-server/docker/alpine.Dockerfile
T
Matiss Janis AboltinsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
f3a5bb3ce5 Revert "[AI] chore: update alpine base image to 3.23.4" (#7985)
* Revert "[AI] chore: update alpine base image to 3.23.4 (#7939)"

This reverts commit 366045a6b0.

* Add release notes for PR #7985

* Delete upcoming-release-notes/7985.md

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-05-28 21:18:31 +00:00

55 lines
1.9 KiB
Docker

FROM node:22-alpine AS builder
# Install required packages
RUN apk add --no-cache python3 openssl build-base
RUN corepack enable
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 if [ "$(uname -m)" = "armv7l" ]; then npm_config_build_from_source=true yarn workspaces focus @actual-app/sync-server --production; else yarn workspaces focus @actual-app/sync-server --production; fi
# 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 alpine:3.22 AS prod
# Minimal runtime dependencies
RUN apk add --no-cache nodejs tini
# Create a non-root user
ARG USERNAME=actual
ARG USER_UID=1001
ARG USER_GID=$USER_UID
RUN addgroup -S ${USERNAME} -g ${USER_GID} && adduser -S ${USERNAME} -G ${USERNAME} -u ${USER_UID}
RUN 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 ["/sbin/tini","-g", "--"]
EXPOSE 5006
CMD ["node", "app.js"]