Compare commits

...

10 Commits

Author SHA1 Message Date
maxlath
2d223df234 nginx: add /assets location to fit Vite build 2025-10-10 16:51:15 +02:00
maxlath
0e31506126 replace shared volume between the inventaire and nginx services by a multi-stage copy
See https://docs.docker.com/build/building/multi-stage/#use-an-external-image-as-a-stage

The shared volume was making updates complicated, as the persisted volume data would not be overriden by the new container
2025-06-29 19:19:03 +02:00
maxlath
513ec266d3 inventaire: docker-entrypoint: fix leveldb directory path
The actual leveldb directory was /opt/inventaire_leveldb-prod instead of /opt/inventaire_leveldb

Made possible by the `suffixDirectoryPathWithDbSuffix` config parameter introduced by https://codeberg.org/inventaire/inventaire/commit/7447c00

Addressing https://codeberg.org/inventaire/docker-inventaire/issues/14
2025-06-03 16:07:16 +02:00
maxlath
524f0b904c scripts: docker_publish: set version tag and push tags 2025-06-03 15:29:35 +02:00
maxlath
eee0f61260 inventaire: update naming
following https://codeberg.org/inventaire/inventaire/commit/91a4dfa7d
2025-05-31 17:46:11 +02:00
maxlath
61d466f7a2 nginx: fix inconsistencies in certbox public file directory
Some where referring to /var/www/html, some to /var/www/certbot: now everything should be in /var/www/html,
that should fix certificate renewal
2025-05-31 16:50:14 +02:00
maxlath
56c2dc08e3 update links after codeberg migration 2025-05-17 12:22:33 +02:00
jums
42ff34d0f0 add .github/README 2025-05-16 17:13:27 +02:00
maxlath
f7e376ca06 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
2025-04-17 15:09:14 +02:00
maxlath
f9419539ba docker-compose.yml: couchdb: increase Erlang I/O threads 2025-03-05 16:24:05 +01:00
8 changed files with 54 additions and 19 deletions

1
.github/README.md vendored Normal file
View File

@@ -0,0 +1 @@
## ⚠️ We moved to Codeberg 👉 https://codeberg.org/inventaire/docker-inventaire

View File

@@ -102,7 +102,7 @@ docker compose up inventaire
Before updating to the latest version, check that there are no breaking changes. Before updating to the latest version, check that there are no breaking changes.
You can find your current version number by visiting fetching the URL `/api/config` on your domain (example: https://inventaire.io/api/config). You can find your current version number by visiting fetching the URL `/api/config` on your domain (example: https://inventaire.io/api/config).
You can find details about the changes since your version on this page: /home/maxlath/code/inventaire/inventaire/CHANGELOG.md. You can find details about the changes since your version on this page: /home/maxlath/code/inventaire/inventaire/CHANGELOG.md.
For changes marked to require data transformation, [some knowledge of CouchDB is recommended](https://docs.couchdb.org/en/stable/intro/index.html), as well as familiarizing yourself with the [recommanded way to export, transform and reimport data in CouchDB](https://github.com/inventaire/inventaire/blob/main/docs/administration/couchdb_data_transformations.md). For changes marked to require data transformation, [some knowledge of CouchDB is recommended](https://docs.couchdb.org/en/stable/intro/index.html), as well as familiarizing yourself with the [recommanded way to export, transform and reimport data in CouchDB](https://git.inventaire.io/inventaire/src/branch/main/docs/administration/couchdb_data_transformations.md).
```sh ```sh
cd docker-inventaire cd docker-inventaire
@@ -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,12 @@ services:
depends_on: depends_on:
- couchdb - couchdb
- elasticsearch - elasticsearch
# Uncomment if you want to access the code:
volumes: volumes:
- 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"
@@ -22,6 +25,9 @@ services:
context: ./couchdb context: ./couchdb
dockerfile: Dockerfile.couchdb dockerfile: Dockerfile.couchdb
env_file: .env env_file: .env
environment:
# See https://docs.couchdb.org/en/stable/maintenance/performance.html#disk-and-file-system-performance
- 'ERL_FLAGS=+A 4'
# Uncomment ports to get access to the db # Uncomment ports to get access to the db
# ie. for database transformation, querying, UI access (http://localhost:5984/_utils/) # ie. for database transformation, querying, UI access (http://localhost:5984/_utils/)
# /!\ Beware that exposing container ports like this might bypass your firewall rules # /!\ Beware that exposing container ports like this might bypass your firewall rules
@@ -61,9 +67,9 @@ services:
volumes: volumes:
- ./nginx/templates:/etc/nginx/templates/ - ./nginx/templates:/etc/nginx/templates/
- ./nginx/snippets:/etc/nginx/snippets - ./nginx/snippets:/etc/nginx/snippets
- inventaire-server:/opt/inventaire - certbot-www:/var/www/html
- 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
@@ -73,9 +79,9 @@ services:
image: certbot/certbot:latest image: certbot/certbot:latest
volumes: volumes:
- ./certbot/conf:/etc/letsencrypt - ./certbot/conf:/etc/letsencrypt
- certbot-www:/var/www/certbot - certbot-www:/var/www/html
restart: unless-stopped restart: unless-stopped
entrypoint: /bin/sh -c "trap exit TERM; while :; do certbot renew --webroot -w /var/www/certbot; sleep 12h & wait $${!}; done;" entrypoint: /bin/sh -c "trap exit TERM; while :; do certbot renew --webroot -w /var/www/html; sleep 12h & wait $${!}; done;"
depends_on: depends_on:
- nginx - nginx
@@ -84,3 +90,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)
@@ -16,8 +16,8 @@ WORKDIR /opt/inventaire
ARG GIT_REF=main ARG GIT_REF=main
ENV DOCKER=1 ENV DOCKER=1
# - 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 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 folder to prevent the client postinstall to run `npm run generate-sitemaps` (which needs to be updated to support non-inventaire.io instances) # - 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)
RUN git clone https://git.inventaire.io/inventaire --depth 1 --branch "${GIT_REF}" . \ RUN git clone https://git.inventaire.io/inventaire --depth 1 --branch "${GIT_REF}" . \
&& mkdir -p /opt/inventaire/client \ && mkdir -p /opt/inventaire/client \
&& npm ci --omit=dev \ && npm ci --omit=dev \
@@ -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,11 @@ module.exports = {
username: '${COUCHDB_USER}', username: '${COUCHDB_USER}',
password: '${COUCHDB_PASSWORD}', password: '${COUCHDB_PASSWORD}',
hostname: 'couchdb', hostname: 'couchdb',
backupDirectory: '/opt/inventaire_backups',
},
leveldb: {
directory: '/opt/inventaire_leveldb',
suffixDirectoryPathWithDbSuffix: false,
}, },
elasticsearch: { elasticsearch: {
origin: 'http://elasticsearch:9200', origin: 'http://elasticsearch:9200',
@@ -53,6 +58,9 @@ module.exports = {
tenantName: '${SWIFT_TENANT_NAME}', tenantName: '${SWIFT_TENANT_NAME}',
region: '${SWIFT_REGION}', region: '${SWIFT_REGION}',
}, },
local: {
directory: '/opt/inventaire_local_media_storage'
},
}, },
} }

View File

@@ -1,5 +1,8 @@
FROM nginx FROM nginx:1.28
RUN [ ! -f /etc/nginx/dhparam.pem ] && openssl dhparam -out /etc/nginx/dhparam.pem 2048 RUN [ ! -f /etc/nginx/dhparam.pem ] && openssl dhparam -out /etc/nginx/dhparam.pem 2048
RUN mkdir -p /tmp/nginx/tmp /tmp/nginx/resize/img/users /tmp/nginx/resize/img/groups /tmp/nginx/resize/img/entities /tmp/nginx/resize/img/remote /tmp/nginx/resize/img/assets && chown -R nginx:nginx /tmp/nginx RUN mkdir -p /tmp/nginx/tmp /tmp/nginx/resize/img/users /tmp/nginx/resize/img/groups /tmp/nginx/resize/img/entities /tmp/nginx/resize/img/remote /tmp/nginx/resize/img/assets /var/cache/nginx/client_temp /opt/inventaire/client && chown -R nginx:nginx /tmp/nginx /opt
# See https://docs.docker.com/build/building/multi-stage/
COPY --from=inventaire/inventaire:latest /opt/inventaire/client /opt/inventaire/client

View File

@@ -108,7 +108,7 @@ server {
proxy_pass http://inv; proxy_pass http://inv;
} }
root /opt/inventaire/client; root /opt/inventaire/client;
location /public { location /public {
include /etc/nginx/snippets/security_headers.conf; include /etc/nginx/snippets/security_headers.conf;
limit_except GET { limit_except GET {
@@ -128,6 +128,15 @@ server {
} }
} }
location /assets {
root /home/admin/inventaire/client/public;
include /etc/nginx/snippets/security_headers.conf;
gzip_static on;
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET,HEAD,OPTIONS";
add_header Access-Control-Allow-Headers "content-type";
}
# Pass the request to the node.js server # Pass the request to the node.js server
# with some correct headers for proxy-awareness # with some correct headers for proxy-awareness
location /api { location /api {
@@ -187,7 +196,7 @@ server {
location ^~ '/.well-known/acme-challenge' { location ^~ '/.well-known/acme-challenge' {
include /etc/nginx/snippets/security_headers.conf; include /etc/nginx/snippets/security_headers.conf;
default_type "text/plain"; default_type "text/plain";
root /var/www/certbot; root /var/www/html;
} }
location / { location / {

View File

@@ -6,7 +6,7 @@ cwd="$PWD"
cd ./inventaire cd ./inventaire
version=$(curl -s https://api.github.com/repos/inventaire/inventaire/tags | jq -r '.[].name' | head -n1 | sed 's/^v//') version=$(curl -s https://codeberg.org/api/v1/repos/inventaire/inventaire/tags | jq -r '.[].name' | head -n1 | sed 's/^v//')
echo -e "Latest version number found: \e[0;32m${version}\e[0m" echo -e "Latest version number found: \e[0;32m${version}\e[0m"
@@ -29,4 +29,7 @@ docker tag inventaire inventaire/inventaire:latest
docker push "inventaire/inventaire:${version}" docker push "inventaire/inventaire:${version}"
docker push inventaire/inventaire:latest docker push inventaire/inventaire:latest
git tag "v${version}"
git push --tags
cd "$cwd" cd "$cwd"