2025-02-26 19:09:29 +01:00
FROM node:20-slim
2025-02-23 08:41:04 +01:00
RUN apt-get update \
2025-02-26 19:09:29 +01:00
&& apt-get install -y curl git graphicsmagick inotify-tools jq \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
2025-04-15 20:39:09 +02:00
&& mkdir -p /opt/inventaire /opt/inventaire_leveldb /opt/inventaire_local_media_storage /opt/inventaire_backups \
2025-02-26 19:09:29 +01:00
&& chown -R 1000:1000 /opt
2025-02-23 08:41:04 +01:00
2025-02-26 19:09:29 +01:00
# Default to the same user as the host (override from command line if needed)
2025-02-23 08:41:04 +01:00
# Known benefits:
# - allows to handle leveldb with level-party from both the host and container at the same time
USER 1000:1000
2025-02-26 19:09:29 +01:00
WORKDIR /opt/inventaire
2025-03-02 23:49:10 +01:00
ARG GIT_REF = main
ENV DOCKER = 1
2025-05-31 17:46:11 +02:00
# - Create the client directory to prevent the server postinstall to run `npm run install-client` as it does it with the wrong workdir and env
# - Create the public/sitemaps directory to prevent the client postinstall to run `npm run generate-sitemaps` (which needs to be updated to support non-inventaire.io instances)
2025-03-02 23:49:10 +01:00
RUN git clone https://git.inventaire.io/inventaire --depth 1 --branch " ${ GIT_REF } " . \
2025-02-26 19:09:29 +01:00
&& mkdir -p /opt/inventaire/client \
&& npm ci --omit= dev \
2025-02-26 19:45:04 +01:00
&& npm run build \
2025-03-02 23:49:10 +01:00
&& git clone https://git.inventaire.io/inventaire-client ./client --branch docker --depth 1 --branch " ${ GIT_REF } " \
2025-02-26 19:09:29 +01:00
&& mkdir -p /opt/inventaire/client/public/sitemaps
WORKDIR /opt/inventaire/client
# Include dev dependencies (webpack, svelte-checks) at first to be able to build during the postinstall script
2025-04-15 20:39:09 +02:00
RUN npm ci --include= dev \
2025-02-26 19:09:29 +01:00
&& rm -rf node_modules \
&& npm ci --omit= dev --ignore-scripts \
&& npm cache clean --force
2025-02-27 19:19:42 +01:00
COPY docker-entrypoint.sh /opt/docker-entrypoint.sh
2025-02-26 19:09:29 +01:00
2025-02-27 19:19:42 +01:00
WORKDIR /opt/inventaire
2025-02-26 23:32:20 +01:00
2025-02-26 19:45:04 +01:00
# Avoid using npm script to start the server
# See https://adambrodziak.pl/dockerfile-good-practices-for-node-and-npm#heading-use-node-not-npm-to-start-the-server
2025-02-27 19:19:42 +01:00
ENTRYPOINT [ "/opt/docker-entrypoint.sh" ]