Skip to content

Commit

Permalink
Add Dockerfile, compose, configs(ref redsolution#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Simakov authored and iamsimakov committed Feb 5, 2021
1 parent 9735856 commit 0faf943
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -y update && \
buildDeps="ca-certificates \
apt-utils \
curl \
gcc \
make \
expat \
libexpat1-dev \
git \
erlang" && \
apt-get install -y --no-install-recommends ${buildDeps} && \
apt-get autoremove -y && \
apt-get clean -y

RUN mkdir /app
WORKDIR /app

RUN mkdir ./xabber-websocket && \
cd xabber-websocket && \
curl -sL https://github.com/redsolution/xabber-websocket/archive/0.3.1.tar.gz | \
tar -zx --strip-components=1 && \
make

FROM ubuntu:20.04

RUN apt-get -y update && \
buildDeps="curl \
nginx" && \
apt-get install -y --no-install-recommends ${buildDeps} && \
apt-get autoremove -y && \
apt-get clean -y

RUN mkdir /app
WORKDIR /app

COPY --from=0 /app/xabber-websocket/_rel/xabber_ws/ ./xabber_ws/
RUN rm -rf /etc/nginx/sites-enabled/default
COPY ./docker/xabber.conf /etc/nginx/conf.d/

COPY . ./

COPY ./docker/entrypoint.sh /usr/local/bin/
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]

CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ]
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.4'
services:
xabber:
build: ./
ports:
- 3080:80
- 3081:8080 # HOST:CONTAINER
restart: always
environment:
CONNECTION_URL: "'ws://localhost:3081/websocket'"
LOG_LEVEL: "'WARN'"

# ALL VALUES SHOULD BE QUOTED, STRINGS DOUBLE QUOTED
# because first quotes will be dropped at run time in ENTRYPOINT

# DEBUG
# XABBER_ACCOUNT_URL
# API_SERVICE_URL
# USE_SOCIAL_AUTH
# DEFAULT_LOGIN_SCREEN
# STORAGE_NAME_ENDING
# TURN_SERVERS_LIST
# DISABLE_LOOKUP_WS
# REGISTER_XMPP_ACCOUNT
39 changes: 39 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
echo 'Start Xabber WS Server...'
/app/xabber_ws/bin/xabber_ws start
echo 'Start Xabber WS Server - OK'

cd /app
cp ./example_index.html ./index.html

VARS=(
CONNECTION_URL
LOG_LEVEL
DEBUG
XABBER_ACCOUNT_URL
API_SERVICE_URL
USE_SOCIAL_AUTH
DEFAULT_LOGIN_SCREEN
STORAGE_NAME_ENDING
TURN_SERVERS_LIST
DISABLE_LOOKUP_WS
REGISTER_XMPP_ACCOUNT
)
for var in ${VARS[@]}
do
echo "Check $var in index.html"
if [ -z ${!var+x} ]; then
echo "$var is empty"
else
grep -q "$var" ./index.html
if [[ $? -eq 0 ]]; then
echo "Replace $var in index.html"
sed "s#$var.*#$var: ${!var},#" ./index.html > ./new_index.html && mv ./new_index.html ./index.html
else
echo "Add value var to index.html"
sed "s/xabber.configure({/a $var: ${!var}," ./index.html > ./new_index.html && mv ./new_index.html ./index.html
fi
fi
done

exec "$@"
12 changes: 12 additions & 0 deletions docker/xabber.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

server {
listen 80 default_server;
server_name _;

root /app;
index index.html;

location / {
try_files $uri $uri/ =404;
}
}

0 comments on commit 0faf943

Please sign in to comment.