docker-compose.yml: add volumes to preserve local images, cache data, and eventual backups

This commit relies on the possibility to customize the LevelDB directory
introduced in https://github.com/inventaire/inventaire/commit/4fb86f6
This commit is contained in:
maxlath
2025-04-15 20:39:09 +02:00
parent f9419539ba
commit f7e376ca06
4 changed files with 23 additions and 6 deletions

View File

@@ -110,9 +110,10 @@ cd docker-inventaire
git pull origin main git pull origin main
# Pull the updated images # Pull the updated images
docker compose pull docker compose pull
# Stop and remove the previous `inventaire` container # Stop and remove the previous containers
# Include the `nginx` container and `--volumes` as otherwise the volume shared between the `inventaire` and the `nginx` container keep the files from the previous image docker compose down
docker compose down inventaire nginx --volumes # Remove the volume hosting inventaire server and client code, to let it be overriden by the updated inventaire image
docker volume rm docker-inventaire_inventaire-server
# Restart containers with the new image (with the --detach option, to be able to close the terminal) # Restart containers with the new image (with the --detach option, to be able to close the terminal)
docker compose up --detach docker compose up --detach
# Check that it restarted without errors # Check that it restarted without errors

View File

@@ -9,9 +9,13 @@ services:
depends_on: depends_on:
- couchdb - couchdb
- elasticsearch - elasticsearch
# Uncomment if you want to access the code:
volumes: volumes:
- inventaire-server:/opt/inventaire - inventaire-server:/opt/inventaire
# The following paths are outside /opt/inventaire so that the inventaire-server volume can be removed
# (as required when updating the server and client) without loosing their data
- inventaire-leveldb:/opt/inventaire_leveldb
- inventaire-local-media-storage:/opt/inventaire_local_media_storage
- inventaire-backups:/opt/inventaire_backups
logging: logging:
options: options:
max-size: "10m" max-size: "10m"
@@ -67,6 +71,7 @@ services:
- inventaire-server:/opt/inventaire - inventaire-server:/opt/inventaire
- certbot-www:/var/www/certbot - certbot-www:/var/www/certbot
- ./certbot/conf:/etc/letsencrypt - ./certbot/conf:/etc/letsencrypt
- nginx-cache:/tmp/nginx
env_file: .env env_file: .env
depends_on: depends_on:
# Required to be able to define the `inventaire` host as an upstream # Required to be able to define the `inventaire` host as an upstream
@@ -87,3 +92,7 @@ volumes:
elasticsearch: elasticsearch:
certbot-www: certbot-www:
inventaire-server: inventaire-server:
inventaire-leveldb:
inventaire-local-media-storage:
inventaire-backups:
nginx-cache:

View File

@@ -3,7 +3,7 @@ FROM node:20-slim
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y curl git graphicsmagick inotify-tools jq \ && apt-get install -y curl git graphicsmagick inotify-tools jq \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \ && apt-get clean && rm -rf /var/lib/apt/lists/* \
&& mkdir -p /opt/inventaire \ && mkdir -p /opt/inventaire /opt/inventaire_leveldb /opt/inventaire_local_media_storage /opt/inventaire_backups \
&& chown -R 1000:1000 /opt && chown -R 1000:1000 /opt
# Default to the same user as the host (override from command line if needed) # Default to the same user as the host (override from command line if needed)
@@ -28,7 +28,7 @@ RUN git clone https://git.inventaire.io/inventaire --depth 1 --branch "${GIT_REF
WORKDIR /opt/inventaire/client WORKDIR /opt/inventaire/client
# Include dev dependencies (webpack, svelte-checks) at first to be able to build during the postinstall script # Include dev dependencies (webpack, svelte-checks) at first to be able to build during the postinstall script
RUN npm ci \ RUN npm ci --include=dev \
&& rm -rf node_modules \ && rm -rf node_modules \
&& npm ci --omit=dev --ignore-scripts \ && npm ci --omit=dev --ignore-scripts \
&& npm cache clean --force && npm cache clean --force

View File

@@ -21,6 +21,10 @@ module.exports = {
username: '${COUCHDB_USER}', username: '${COUCHDB_USER}',
password: '${COUCHDB_PASSWORD}', password: '${COUCHDB_PASSWORD}',
hostname: 'couchdb', hostname: 'couchdb',
backupFolder: '/opt/inventaire_backups',
},
leveldb: {
folder: '/opt/inventaire_leveldb'
}, },
elasticsearch: { elasticsearch: {
origin: 'http://elasticsearch:9200', origin: 'http://elasticsearch:9200',
@@ -53,6 +57,9 @@ module.exports = {
tenantName: '${SWIFT_TENANT_NAME}', tenantName: '${SWIFT_TENANT_NAME}',
region: '${SWIFT_REGION}', region: '${SWIFT_REGION}',
}, },
local: {
folder: '/opt/inventaire_local_media_storage'
},
}, },
} }