Skip to content

Commit

Permalink
dockerized
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRoehm committed Sep 27, 2022
1 parent 700d7b4 commit 4e7c747
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 9 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
test
.github
.vscode
nextcloud
production
config
certs
config.*
docker*
Docker*
.git*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ config.yml
production
nextcloud
certs
config
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:18
LABEL authors="Alex Roehm"
# update dependencies and install curl
RUN apt-get update && apt-get install -y \
curl dumb-init\
&& rm -rf /var/lib/apt/lists/*

# Create app directory
WORKDIR /ldap
RUN chown 1000:1000 .

COPY --chown=node:node . .

USER 1000:1000

# update each dependency in package.json to the latest version
ENV NODE_ENV=production
RUN yarn install --production

EXPOSE 1389
ENTRYPOINT [ "dumb-init", "node", "." ]
17 changes: 12 additions & 5 deletions config.example.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
server:
port: 1389
ip: 0.0.0.0
updateinterval: 600 // intervall in seconds
cert: certs/ldap.crt
key: certs/ldap.key
sites:
ccf:
site:
Expand All @@ -8,19 +14,20 @@ sites:
ldap:
o: Organisation Name
dc: dc=myorg,dc=tld // domain components
admin: admin
admincn: admin
password: secret2
port: 1389
cert: certs/ldap.crt
key: certs/ldap.key
attributes: // fields to add to user
- name: key1
default: defaultvalue1
replacements: // add value to user with id
- id: 156
- id: id
value: extra
- name: key2
default: defaultvalue2
adminGroup:
cn: "admin" //
members: // personid s of users to put in admin group
- id
selectionGroupIds: // ChurchTools Group Ids - only members of these groups will be served by ldap
- gid
- gid
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.1'

services:
ccf-ctldap:
image: ccf-ctldap
ports:
- 1389:1389
volumes:
- ./config:/ldap/config
- ./certs:/ldap/certs
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const log = require('./src/logging');
const nc = require('./src/nextcloud');
const fs = require('fs');
const { argv } = require('process');
const pino = require('pino')
const pretty = require('pino-pretty')

function write(name, data) {
try {
Expand Down Expand Up @@ -71,7 +73,7 @@ run = async () => {
} else if (process.argv.includes('--testsnapshot')) {
sanpshot();
} else {
log.logger.level = 'info'
log.logger = pino({ level: 'info', transport: { target: 'pino-pretty' } })
const config = main.getConfig(c.CONFIG_FILE)
start = await main.start(
config,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"ldapjs": "^2.3.1",
"path": "^0.12.7",
"pino": "^8.6.0",
"yamljs": "^0.3.0"
"yamljs": "^0.3.0",
"pino-pretty": "^9.1.0"

}
}
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports.CONFIG_FILE = "./production/config.yml"
exports.CONFIG_FILE = "/ldap/config/config.yml"
exports.API_SLUG = "api"
exports.WHOAMI_AP = "/whoami?only_allow_authenticated=true"
exports.CSRF_AP = "/csrftoken"
Expand Down
1 change: 0 additions & 1 deletion src/ldapcache.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const c = require('./constants')
const log = require('./logging')
var ldapEsc = require('ldap-escape');
const { use } = require('chai');

ldapcache = []

Expand Down

0 comments on commit 4e7c747

Please sign in to comment.