## This Dockerfile is auto-generated by scripts/buildDockerfile.ts

FROM node:24-alpine as builder

RUN apk update && apk upgrade

WORKDIR /app-build
COPY .dev.mk .
COPY bin ./bin
COPY package.json .
COPY package-lock.json .
COPY rollup.config.mjs .
COPY tsconfig.json .
COPY scripts ./scripts
COPY src ./src
COPY static ./static
RUN npm ci && NODE_ENV=production node_modules/.bin/rollup -c && npm pack && mv *.tgz /tmp/app.tgz

WORKDIR /app
RUN npm install --no-package-lock /tmp/app.tgz && rm -f /tmp/app.tgz && rm -rf /app-build && npm cache clean --force

ENV NODE_ENV=production \
 DM_PORT="8081" \
 DM_PLUGINS=core/static,core/helloworld \
 DM_LOG_LEVEL="notice" \
 DM_LOGGER="console" \
 DM_API_PREFIX="/api" \
 DM_MAIL_DOMAIN= \
 DM_LDAP_BASE= \
 DM_LDAP_DN="cn=admin,dc=example,dc=com" \
 DM_LDAP_PWD="admin" \
 DM_LDAP_URL=ldap://localhost \
 DM_LDAP_USER_ATTRIBUTE="uid" \
 DM_LDAP_CACHE_MAX="1000" \
 DM_LDAP_CACHE_TTL="300" \
 DM_LDAP_POOL_SIZE="5" \
 DM_LDAP_CONNECTION_TTL="60" \
 DM_SCHEMAS_PATH="/app/node_modules/ldap-rest/static/schemas" \
 DM_MAIL_ATTRIBUTE="mail" \
 DM_QUOTA_ATTRIBUTE="mailQuota" \
 DM_DELEGATION_ATTRIBUTE="twakeDelegatedUsers" \
 DM_ALIAS_ATTRIBUTE="mailAlternateAddress" \
 DM_FORWARD_ATTRIBUTE="mailForwardingAddress" \
 DM_DISPLAY_NAME_ATTRIBUTE="displayName" \
 DM_DRIVE_QUOTA_ATTRIBUTE="twakeDriveQuota" \
 DM_USER_CLASSES=top,twakeAccount,twakeWhitePages \
 DM_LDAP_TOP_ORGANIZATION= \
 DM_LDAP_ORGANIZATION_CLASSES=top,organizationalUnit,twakeDepartment \
 DM_LDAP_ORGANIZATION_LINK_ATTRIBUTE="twakeDepartmentLink" \
 DM_LDAP_ORGANIZATION_PATH_ATTRIBUTE="twakeDepartmentPath" \
 DM_LDAP_ORGANIZATION_PATH_SEPARATOR=" / " \
 DM_LDAP_ORGANIZATION_MAX_SUBNODES="50" \
 DM_LDAP_GROUP_BASE= \
 DM_LDAP_GROUPS_MAIN_ATTRIBUTE="cn" \
 DM_GROUP_CLASSES=top,groupOfNames \
 DM_ALLOW_UNEXISTENT_MEMBERS=false \
 DM_GROUP_DEFAULT_ATTRIBUTES="{}" \
 DM_GROUP_DUMMY_USER="cn=fakeuser" \
 DM_GROUP_SCHEMA="/app/node_modules/ldap-rest/static/schemas/twake/groups.json" \
 DM_EXTERNAL_MEMBERS_BRANCH="ou=contacts,dc=example,dc=com" \
 DM_EXTERNAL_BRANCH_CLASSES=top,inetOrgPerson \
 DM_STATIC_PATH="/app/node_modules/ldap-rest/static" \
 DM_STATIC_NAME="static" \
 DM_LDAP_FLAT_SCHEMA= \
 DM_BULK_IMPORT_SCHEMAS= \
 DM_BULK_IMPORT_MAX_FILE_SIZE="10485760" \
 DM_BULK_IMPORT_BATCH_SIZE="100" \
 DM_JAMES_WEBADMIN_URL="http://localhost:8000" \
 DM_JAMES_WEBADMIN_TOKEN= \
 DM_JAMES_SIGNATURE_TEMPLATE= \
 DM_LDAP_CONCURRENCY="10" \
 DM_JAMES_CONCURRENCY="10" \
 DM_JAMES_INIT_DELAY="1000" \
 DM_JAMES_MAILING_LIST_BRANCHES= \
 DM_JAMES_MAILBOX_TYPE_ATTRIBUTE="twakeMailboxType" \
 DM_TWAKE_DRIVE_WEBADMIN_URL= \
 DM_TWAKE_DRIVE_WEBADMIN_TOKEN= \
 DM_TWAKE_DRIVE_CONCURRENCY="10" \
 DM_TWAKE_DRIVE_DOMAIN_ATTRIBUTE="twakeCozyDomain" \
 DM_TWAKE_DRIVE_DEFAULT_DOMAIN_TEMPLATE= \
 DM_CALENDAR_WEBADMIN_URL="http://localhost:8080" \
 DM_CALENDAR_WEBADMIN_TOKEN= \
 DM_CALENDAR_CONCURRENCY="10" \
 DM_CALENDAR_RESOURCE_BASE= \
 DM_CALENDAR_RESOURCE_OBJECTCLASS= \
 DM_CALENDAR_RESOURCE_CREATOR= \
 DM_CALENDAR_RESOURCE_DOMAIN= \
 DM_CALENDAR_FIRSTNAME_ATTRIBUTE="givenName" \
 DM_CALENDAR_LASTNAME_ATTRIBUTE="sn" \
 DM_COZY_ADMIN_URL= \
 DM_COZY_ADMIN_USER="admin" \
 DM_COZY_ADMIN_PASSPHRASE= \
 DM_COZY_ORG_ID= \
 DM_COZY_ORG_DOMAIN= \
 DM_COZY_DEFAULT_LOCALE="fr" \
 DM_COZY_CONTEXT_NAME="default" \
 DM_COZY_APPS="home,drive,settings,notes,dataproxy" \
 DM_COZY_AUTH_EXCHANGE="auth" \
 DM_COZY_B2B_EXCHANGE="b2b" \
 DM_COZY_USER_CREATED_ROUTING_KEY="user.created" \
 DM_COZY_USER_DELETED_ROUTING_KEY="domain.user.deleted" \
 DM_CLOUDERY_MANAGER_URL= \
 DM_CLOUDERY_MANAGER_TOKEN= \
 DM_CLOUDERY_OFFER="b2b_twake_default" \
 DM_CLOUDERY_DOMAIN= \
 DM_CLOUDERY_USER_BRANCH= \
 DM_CLOUDERY_ORG_ID_HEADER="x-cloudery-org-id" \
 DM_CLOUDERY_ORG_ROLE_HEADER="x-cloudery-org-role" \
 DM_CLOUDERY_DEFAULT_ORG_ROLE="member" \
 DM_CLOUDERY_FQDN_ATTRIBUTE="twakeWorkspaceUrl" \
 DM_CLOUDERY_ORG_ID_ATTRIBUTE="twakeOrganizationId" \
 DM_CLOUDERY_ORG_ROLE_ATTRIBUTE="twakeOrganizationRole" \
 DM_CLOUDERY_PHONES_ATTRIBUTE="twakePhones" \
 DM_CLOUDERY_INVITED_ATTRIBUTE="twakeInvited" \
 DM_CLOUDERY_DEFAULT_LOCALE="en" \
 DM_CLOUDERY_WORKFLOW_POLL_INTERVAL_MS="2000" \
 DM_CLOUDERY_WORKFLOW_MAX_ATTEMPTS="60" \
 DM_RABBITMQ_URL= \
 DM_APPLICATIVE_ACCOUNT_BASE= \
 DM_MAX_APP_ACCOUNTS="5" \
 DM_LDAP_OPERATIONAL_ATTRIBUTES=dn,controls,structuralObjectClass,entryUUID,entryDN,subschemaSubentry,modifyTimestamp,modifiersName,createTimestamp,creatorsName,userPassword \
 DM_TRASH_BASE= \
 DM_TRASH_WATCHED_BASES= \
 DM_TRASH_ADD_METADATA="true" \
 DM_TRASH_AUTO_CREATE="true" \
 DM_LLNG_INI="/etc/lemonldap-ng/lemonldap-ng.ini" \
 DM_AUTH_TOKENS= \
 DM_AUTH_TOTP= \
 DM_AUTH_TOTP_WINDOW="1" \
 DM_AUTH_TOTP_STEP="30" \
 DM_AUTH_HMAC= \
 DM_AUTH_HMAC_WINDOW="120000" \
 DM_AUTHZ_PER_ROUTES= \
 DM_AUTHZ_PER_BRANCH_CONFIG="{\"default\":{\"read\":true,\"write\":false,\"delete\":false}}" \
 DM_AUTHZ_PER_BRANCH_CACHE_TTL="60" \
 DM_AUTHZ_DYNAMIC_BASE= \
 DM_AUTHZ_DYNAMIC_CACHE_TTL="60" \
 DM_AUTHZ_DYNAMIC_TOKEN_ATTRIBUTE="userPassword" \
 DM_AUTHZ_DYNAMIC_CONFIG_ATTRIBUTE="description" \
 DM_AUTHZ_DYNAMIC_TENANT_ATTRIBUTE="cn" \
 DM_AUTHZ_DYNAMIC_RELOAD_ENDPOINT=false \
 DM_AUTHZ_LOCAL_ADMIN_ATTRIBUTE="twakeLocalAdminLink" \
 DM_OIDC_SERVER= \
 DM_OIDC_CLIENT_ID= \
 DM_OIDC_CLIENT_SECRET= \
 DM_BASE_URL= \
 DM_RATE_LIMIT_WINDOW_MS="900000" \
 DM_RATE_LIMIT_MAX="100" \
 DM_CROWDSEC_URL="http://localhost:8080/v1/decisions" \
 DM_CROWDSEC_API_KEY= \
 DM_CROWDSEC_CACHE_TTL="60" \
 DM_TRUSTED_PROXIES= \
 DM_TRUSTED_PROXY_AUTH_HEADER="Auth-User" \
 DM_PPOLICY_DEFAULT_DN= \
 DM_PPOLICY_WARN_DAYS="14" \
 DM_PPOLICY_VALIDATE_COMPLEXITY=false \
 DM_PPOLICY_MIN_LENGTH="12" \
 DM_PPOLICY_REQUIRE_UPPERCASE=true \
 DM_PPOLICY_REQUIRE_LOWERCASE=true \
 DM_PPOLICY_REQUIRE_DIGIT=true \
 DM_PPOLICY_REQUIRE_SPECIAL=true \
 DM_LDAP_USERS_BASE= \
 DM_SCIM_PREFIX="/scim/v2" \
 DM_SCIM_USER_BASE= \
 DM_SCIM_GROUP_BASE= \
 DM_SCIM_USER_BASE_TEMPLATE= \
 DM_SCIM_GROUP_BASE_TEMPLATE= \
 DM_SCIM_BASE_MAP= \
 DM_SCIM_USER_BASE_HEADER= \
 DM_SCIM_GROUP_BASE_HEADER= \
 DM_SCIM_BASE_HEADER_ROOT= \
 DM_SCIM_USER_OBJECT_CLASSES=top,inetOrgPerson,organizationalPerson,person \
 DM_SCIM_USER_RDN_ATTRIBUTE="uid" \
 DM_SCIM_GROUP_OBJECT_CLASSES=top,groupOfNames \
 DM_SCIM_GROUP_RDN_ATTRIBUTE="cn" \
 DM_SCIM_ID_ATTRIBUTE="rdn" \
 DM_SCIM_USER_MAPPING= \
 DM_SCIM_GROUP_MAPPING= \
 DM_SCIM_MAX_RESULTS="200" \
 DM_SCIM_BULK_MAX_OPERATIONS="100" \
 DM_SCIM_BULK_MAX_PAYLOAD_SIZE="1048576" \
 DM_SCIM_ETAG=false \
 DM_SCIM_BASE_URL=

USER node

EXPOSE 8081
CMD ["npx", "ldap-rest"]
