diff --git a/.gitignore b/.gitignore index 593157c..db5a89d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -inventaire .env data log diff --git a/docker-compose.yml b/docker-compose.yml index 04f38e8..c2b7484 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,6 @@ services: inventaire: - image: inventaire:latest - volumes: - - ./inventaire:/opt/inventaire + image: inventaire/inventaire:latest env_file: .env depends_on: - couchdb diff --git a/dotenv b/dotenv index baa84c7..88235c0 100644 --- a/dotenv +++ b/dotenv @@ -6,12 +6,21 @@ PROJECT_ROOT=/opt/inventaire # Generic user, to modify only for good reason COUCHDB_USER=couchdb - # Consider passwords with no less than 32 charracters, for example: # cat /dev/urandom | tr -dc A-Za-z0-9-_ | head -c 32 COUCHDB_PASSWORD=your_password NODE_ENV=production NODE_APP_INSTANCE=federated -# Matching the port defined in inventaire/config/production-federated.cjs + +# Conventional port for Inventaire server in federated mode INVENTAIRE_PORT=3016 + +INSTANCE_NAME='My Inventaire Instance' + +# Will be displayed on landing screen +ORG_NAME='Example Organization' +ORG_URL='https://inventaire.example.org' + +# Users receiving emails from the instance can reply to this +CONTACT_ADDRESS='contact@inventaire.example.org' diff --git a/Dockerfile.inventaire b/inventaire/Dockerfile.inventaire similarity index 94% rename from Dockerfile.inventaire rename to inventaire/Dockerfile.inventaire index a4dabc9..ca32c40 100644 --- a/Dockerfile.inventaire +++ b/inventaire/Dockerfile.inventaire @@ -32,6 +32,8 @@ RUN npm ci \ 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 -CMD [ "./scripts/typescript/start_built_server.sh" ] +ENTRYPOINT [ "./docker-entrypoint.sh" ] diff --git a/inventaire/docker-entrypoint.sh b/inventaire/docker-entrypoint.sh new file mode 100755 index 0000000..bc80676 --- /dev/null +++ b/inventaire/docker-entrypoint.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -eu + +# Overwrite the local config with environment variables every time the container is restarted +cat > ./config/local.cjs << EOF +module.exports = { + port: '${INVENTAIRE_PORT}', + publicHostname: '${PUBLIC_HOSTNAME}', + instanceName: '${INSTANCE_NAME}', + orgName: '${ORG_NAME}', + orgUrl: '${ORG_URL}', + contactAddress: '${CONTACT_ADDRESS}', + + db: { + username: '${COUCHDB_USER}', + password: '${COUCHDB_PASSWORD}', + hostname: 'couchdb', + }, + elasticsearch: { + origin: 'http://elasticsearch:9200', + } +} +EOF + +./scripts/typescript/start_built_server.sh