init
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
libgmp10 \
|
||||
socat \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ARG SIMPLEX_CHAT_VERSION
|
||||
ARG TARGETARCH
|
||||
|
||||
RUN case "$TARGETARCH" in \
|
||||
amd64) simplex_arch=x86_64 ;; \
|
||||
arm64) simplex_arch=aarch64 ;; \
|
||||
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
|
||||
esac \
|
||||
&& curl -fsSL \
|
||||
"https://github.com/simplex-chat/simplex-chat/releases/download/${SIMPLEX_CHAT_VERSION}/simplex-chat-ubuntu-22_04-${simplex_arch}" \
|
||||
-o /tmp/simplex-chat \
|
||||
&& install -m 755 /tmp/simplex-chat /usr/local/bin/simplex-chat \
|
||||
&& rm /tmp/simplex-chat
|
||||
|
||||
COPY --chmod=755 entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
COPY bot_avatar.jpeg /simplex/bot_avatar.jpeg
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
DB_DIR="/simplex/data"
|
||||
DB_PREFIX="simplex"
|
||||
BOT_NAME="${SIMPLEX_BOT_DISPLAY_NAME}"
|
||||
BOT_DESCRIPTION="${SIMPLEX_BOT_DESCRIPTION}"
|
||||
BOT_AVATAR="/simplex/bot_avatar.jpeg"
|
||||
INTERNAL_PORT=5226
|
||||
EXTERNAL_PORT=5225
|
||||
|
||||
has_chat_db() {
|
||||
find "$DB_DIR" -maxdepth 1 -type f -name '*.db' 2>/dev/null | grep -q .
|
||||
}
|
||||
|
||||
mkdir -p "$DB_DIR"
|
||||
cd "$DB_DIR"
|
||||
|
||||
echo "Starting socat proxy (0.0.0.0:$EXTERNAL_PORT -> 127.0.0.1:$INTERNAL_PORT)..."
|
||||
socat TCP-LISTEN:$EXTERNAL_PORT,fork,reuseaddr TCP:127.0.0.1:$INTERNAL_PORT &
|
||||
|
||||
DB_ARGS=(-d "$DB_PREFIX")
|
||||
ARGS=("${DB_ARGS[@]}" -p "$INTERNAL_PORT")
|
||||
|
||||
if ! has_chat_db; then
|
||||
echo "First run detected. Creating bot profile: $BOT_NAME"
|
||||
AVATAR_DATA="$(base64 -w 0 "$BOT_AVATAR")"
|
||||
|
||||
simplex-chat \
|
||||
--create-bot-display-name "$BOT_NAME" \
|
||||
"${DB_ARGS[@]}" \
|
||||
-e "/_profile 1 {\"displayName\":\"$BOT_NAME\",\"fullName\":\"$BOT_NAME\",\"shortDescr\":\"$BOT_DESCRIPTION\",\"image\":\"$AVATAR_DATA\"}"
|
||||
fi
|
||||
|
||||
echo "Starting SimpleX CLI in API mode on internal port $INTERNAL_PORT..."
|
||||
exec simplex-chat "${ARGS[@]}"
|
||||
Reference in New Issue
Block a user