inventaire service: use a custom entrypoint script

to initialize the local config from env variables
This commit is contained in:
maxlath
2025-02-26 23:32:20 +01:00
parent 1b94320cb2
commit 80b8985198
5 changed files with 41 additions and 7 deletions

View File

@@ -0,0 +1,39 @@
FROM node:20-slim
RUN apt-get update \
&& apt-get install -y curl git graphicsmagick inotify-tools jq \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
&& mkdir -p /opt/inventaire \
&& chown -R 1000:1000 /opt
# Default to the same user as the host (override from command line if needed)
# Known benefits:
# - allows to handle leveldb with level-party from both the host and container at the same time
USER 1000:1000
WORKDIR /opt/inventaire
# - Create the client folder 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 folder to prevent the client postinstall to run `npm run generate-sitemaps` (which needs to be updated to support non-inventaire.io instances)
RUN git clone http://github.com/inventaire/inventaire --depth 1 . \
&& mkdir -p /opt/inventaire/client \
&& npm ci --omit=dev \
&& npm run build \
&& git clone https://github.com/inventaire/inventaire-client.git ./client --branch docker --depth 1 \
&& 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
RUN npm ci \
&& rm -rf node_modules \
&& npm ci --omit=dev --ignore-scripts \
&& npm cache clean --force
WORKDIR /opt/inventaire
COPY docker-entrypoint.sh docker-entrypoint.sh
# 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
ENTRYPOINT [ "./docker-entrypoint.sh" ]