mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-02 22:00:34 +01:00
* feat: disable uneecessary npm features disables npm audit, fund and update-notifier for a few second startup speedup * fix: make default actually defaults not forced values * feat: upgrade on container changes * feat: support changing build verb * fix: use local volumes instead of bind mounts * fix: save just the hash without any unexpected whitespace * feat: use run with mount instead of copying for cross-platfomr builds * ci: try with minimal cache * ci: don't fetch all branches * feat: bsic support for other package managers via PACKAGE_MANAGER env var * refactor: better structured entrypoint Co-authored-by: NavyStack <137406386+NavyStack@users.noreply.github.com> * ci: properly cache the node_modules mount * fix: syntax error * refactor: fine tune docker-related files * ci: docker image taging (time, latest) * fix: remove the trailing slash for correct directory path * docker: todo- use environment variables to create files * docker: fix permissions * docker: fix permissions * docker: fix stage * feat: auto-upgrade on package.json changes * fix: don't profile-gate postgres --------- Co-authored-by: NavyStack <137406386+NavyStack@users.noreply.github.com> Co-authored-by: NavyStack <navystack@askfront.com>
74 lines
2.5 KiB
Docker
74 lines
2.5 KiB
Docker
FROM node:lts as build
|
|
|
|
ENV NODE_ENV=production \
|
|
DAEMON=false \
|
|
SILENT=false \
|
|
USER=nodebb \
|
|
UID=1001 \
|
|
GID=1001
|
|
|
|
WORKDIR /usr/src/app/
|
|
|
|
COPY . /usr/src/app/
|
|
|
|
# Install corepack to allow usage of other package managers
|
|
RUN corepack enable
|
|
|
|
# Removing unnecessary files for us
|
|
RUN find . -mindepth 1 -maxdepth 1 -name '.*' ! -name '.' ! -name '..' -exec bash -c 'echo "Deleting {}"; rm -rf {}' \;
|
|
|
|
# Prepage package.json
|
|
RUN cp /usr/src/app/install/package.json /usr/src/app/
|
|
|
|
RUN apt-get update \
|
|
&& DEBIAN_FRONTEND=noninteractive \
|
|
apt-get -y --no-install-recommends install \
|
|
tini
|
|
|
|
RUN groupadd --gid ${GID} ${USER} \
|
|
&& useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \
|
|
&& chown -R ${USER}:${USER} /usr/src/app/
|
|
|
|
USER ${USER}
|
|
|
|
RUN npm install --omit=dev
|
|
# TODO: generate lockfiles for each package manager
|
|
## pnpm import \
|
|
|
|
FROM node:lts-slim AS final
|
|
|
|
ENV NODE_ENV=production \
|
|
DAEMON=false \
|
|
SILENT=false \
|
|
USER=nodebb \
|
|
UID=1001 \
|
|
GID=1001
|
|
|
|
WORKDIR /usr/src/app/
|
|
|
|
COPY --from=build --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/install/docker/setup.json /usr/src/app/
|
|
COPY --from=build --chown=${USER}:${USER} /usr/bin/tini /usr/src/app/install/docker/entrypoint.sh /usr/local/bin/
|
|
|
|
RUN corepack enable \
|
|
&& groupadd --gid ${GID} ${USER} \
|
|
&& useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \
|
|
&& mkdir -p /usr/src/app/logs/ /opt/config/ \
|
|
&& chown -R ${USER}:${USER} /usr/src/app/ /opt/config/ \
|
|
&& chmod +x /usr/local/bin/entrypoint.sh \
|
|
&& chmod +x /usr/local/bin/tini
|
|
|
|
# TODO: Have docker-compose use environment variables to create files like setup.json and config.json.
|
|
# COPY --from=hairyhenderson/gomplate:stable /gomplate /usr/local/bin/gomplate
|
|
|
|
USER ${USER}
|
|
|
|
EXPOSE 4567
|
|
|
|
VOLUME ["/usr/src/app/node_modules", "/usr/src/app/build", "/usr/src/app/public/uploads", "/opt/config/"]
|
|
|
|
# Utilising tini as our init system within the Docker container for graceful start-up and termination.
|
|
# Tini serves as an uncomplicated init system, adept at managing the reaping of zombie processes and forwarding signals.
|
|
# This approach is crucial to circumvent issues with unmanaged subprocesses and signal handling in containerised environments.
|
|
# By integrating tini, we enhance the reliability and stability of our Docker containers.
|
|
# Ensures smooth start-up and shutdown processes, and reliable, safe handling of signal processing.
|
|
ENTRYPOINT ["tini", "--", "entrypoint.sh"] |