Skip to content

Commit 9d691e1

Browse files
authored
Setup image (#1)
1 parent 8c70a0e commit 9d691e1

File tree

7 files changed

+155
-30
lines changed

7 files changed

+155
-30
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
data.json
2+
.env

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
data.json
2+
.env

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM debian:bookworm-slim
2+
3+
ARG BWDC_VERSION=2026.1.0
4+
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
libsecret-1-0 \
7+
curl \
8+
unzip \
9+
ca-certificates \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
RUN curl -L "https://github.com/bitwarden/directory-connector/releases/download/v${BWDC_VERSION}/bwdc-linux-${BWDC_VERSION}.zip" -o /tmp/bwdc.zip && \
13+
unzip /tmp/bwdc.zip -d /usr/local/bin && \
14+
chmod +x /usr/local/bin/bwdc && \
15+
rm /tmp/bwdc.zip
16+
17+
RUN useradd -r -s /bin/false bitwarden && \
18+
mkdir -p /home/bitwarden/.config/Bitwarden\ Directory\ Connector && \
19+
chown -R bitwarden:bitwarden /home/bitwarden
20+
21+
COPY entrypoint.sh /entrypoint.sh
22+
RUN chmod +x /entrypoint.sh && sed -i 's/\r$//' /entrypoint.sh
23+
24+
ENV BITWARDENCLI_CONNECTOR_PLAINTEXT_SECRETS=true
25+
26+
USER bitwarden
27+
28+
ENTRYPOINT ["/entrypoint.sh"]

LICENSE

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
BSD 3-Clause License
2-
3-
Copyright (c) 2026, ACM@UIUC
4-
5-
Redistribution and use in source and binary forms, with or without
6-
modification, are permitted provided that the following conditions are met:
7-
8-
1. Redistributions of source code must retain the above copyright notice, this
9-
list of conditions and the following disclaimer.
10-
11-
2. Redistributions in binary form must reproduce the above copyright notice,
12-
this list of conditions and the following disclaimer in the documentation
13-
and/or other materials provided with the distribution.
14-
15-
3. Neither the name of the copyright holder nor the names of its
16-
contributors may be used to endorse or promote products derived from
17-
this software without specific prior written permission.
18-
19-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2026, ACM@UIUC
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# bitwarden-dc-docker
2-
Running the Bitwarden Directory Connector on Docker
1+
# Bitwarden Directory Connector Docker
2+
Running the Bitwarden Directory Connector on Docker

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
bwdc:
3+
build:
4+
context: .
5+
args:
6+
BWDC_VERSION: 2026.1.0
7+
restart: unless-stopped
8+
environment:
9+
- BW_SERVER
10+
- BW_CLIENTID
11+
- BW_CLIENTSECRET
12+
- BW_DIRECTORY_TYPE
13+
- BW_DIRECTORY_KEY
14+
- SYNC_INTERVAL_MIN
15+
volumes:
16+
- ./data.json:/home/bitwarden/.config/Bitwarden Directory Connector/data.json

entrypoint.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh
2+
set -e
3+
4+
CONFIG_DIR="/home/bitwarden/.config/Bitwarden Directory Connector"
5+
CONFIG_FILE="${CONFIG_DIR}/data.json"
6+
7+
if [ ! -f "$CONFIG_FILE" ]; then
8+
echo "ERROR: Configuration file not found!"
9+
echo "Please mount your data.json to: ${CONFIG_FILE}"
10+
echo ""
11+
echo "Example:"
12+
echo " docker run -v /path/to/data.json:\"${CONFIG_FILE}\":ro ..."
13+
echo ""
14+
echo "You can generate a data.json using the Bitwarden Directory Connector desktop app,"
15+
echo "or by running this container interactively:"
16+
echo " docker run -it --entrypoint /bin/sh <image>"
17+
echo " bwdc login"
18+
echo " bwdc config directory <type>"
19+
echo " bwdc data-file"
20+
exit 1
21+
fi
22+
23+
SYNC_INTERVAL_MIN=${SYNC_INTERVAL_MIN:-5}
24+
SYNC_INTERVAL_SEC=$((SYNC_INTERVAL_MIN * 60))
25+
26+
echo "Sync interval: every ${SYNC_INTERVAL_MIN} minutes."
27+
28+
if [ -n "$BW_SERVER" ]; then
29+
echo "Configuring server: ${BW_SERVER}"
30+
/usr/local/bin/bwdc config server "${BW_SERVER}"
31+
fi
32+
33+
if [ -n "$BW_DIRECTORY_TYPE" ]; then
34+
echo "Configuring directory type: ${BW_DIRECTORY_TYPE}"
35+
/usr/local/bin/bwdc config directory "${BW_DIRECTORY_TYPE}"
36+
fi
37+
38+
# Configure directory-specific secret key based on directory type
39+
if [ -n "$BW_DIRECTORY_KEY" ]; then
40+
case "${BW_DIRECTORY_TYPE}" in
41+
0|ldap)
42+
echo "Configuring LDAP password..."
43+
/usr/local/bin/bwdc config ldap.password "${BW_DIRECTORY_KEY}"
44+
;;
45+
1|azure)
46+
echo "Configuring Azure AD key..."
47+
/usr/local/bin/bwdc config azure.key "${BW_DIRECTORY_KEY}"
48+
;;
49+
2|gsuite)
50+
echo "Configuring GSuite key..."
51+
/usr/local/bin/bwdc config gsuite.key "${BW_DIRECTORY_KEY}"
52+
;;
53+
3|okta)
54+
echo "Configuring Okta token..."
55+
/usr/local/bin/bwdc config okta.token "${BW_DIRECTORY_KEY}"
56+
;;
57+
4|onelogin)
58+
echo "Configuring OneLogin secret..."
59+
/usr/local/bin/bwdc config onelogin.secret "${BW_DIRECTORY_KEY}"
60+
;;
61+
*)
62+
echo "WARNING: BW_DIRECTORY_KEY set but BW_DIRECTORY_TYPE not recognized: ${BW_DIRECTORY_TYPE}"
63+
echo "Valid types: 0 (ldap), 1 (azure), 2 (gsuite), 3 (okta), 4 (onelogin)"
64+
;;
65+
esac
66+
fi
67+
68+
echo "Logging in..."
69+
/usr/local/bin/bwdc login || echo "Already logged in, continuing..."
70+
71+
echo "Starting sync loop..."
72+
while true; do
73+
echo "[$(date)] Running sync..."
74+
/usr/local/bin/bwdc sync
75+
echo "Sleeping for ${SYNC_INTERVAL_SEC} seconds..."
76+
sleep "${SYNC_INTERVAL_SEC}"
77+
done

0 commit comments

Comments
 (0)