From 2cb899d79cb847e2c81eefc43e07caf61255ac8e Mon Sep 17 00:00:00 2001 From: Azlux Date: Sun, 21 Jun 2020 02:26:57 +0200 Subject: [PATCH] Add docker --- .drone.yml | 21 +++++++++++++++++++++ Dockerfile | 23 +++++++++++++++++++++++ entrypoint.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/.drone.yml b/.drone.yml index 13d725b..e3f1328 100644 --- a/.drone.yml +++ b/.drone.yml @@ -29,6 +29,16 @@ steps: - master event: - push + + - name: docker + image: plugins/docker + settings: + repo: azlux/botamusique + username: + from_secret: docker_username + password: + from_secret: docker_password + tags: testing - name: deploy-stable image: debian @@ -43,6 +53,17 @@ steps: - master event: - tag + + - name: docker + image: plugins/docker + settings: + repo: azlux/botamusique + username: + from_secret: docker_username + password: + from_secret: docker_password + tags: latest + volumes: - name: repo diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b53027d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:slim +ENV DEBIAN_FRONTEND noninteractive + +EXPOSE 8181 + +RUN apt update && \ + apt install -y opus-tools ffmpeg libmagic-dev curl tar && \ + rm -rf /var/lib/apt/lists/* + +COPY . /botamusique + +WORKDIR /botamusique + +RUN rm -rf .git* + +RUN python3 -m venv venv && \ + venv/bin/pip install wheel && \ + venv/bin/pip install -r requirements.txt + +RUN chmod +x entrypoint.sh + +ENTRYPOINT [ "/botamusique/entrypoint.sh" ] +CMD ["venv/bin/python", "mumbleBot.py"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..15a0e98 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +command=( "${@}" ) + +if [ -n "$BAM_DB" ]; then + command+=( "--db" "$BAM_DB" ) +fi + +if [ -n "$BAM_MUSIC_DB" ]; then + command+=( "--music-db" "$BAM_MUSIC_DB" ) +fi + +if [ -n "$BAM_MUMBLE_SERVER" ]; then + command+=( "--server" "$BAM_MUMBLE_SERVER") +fi + +if [ -n "$BAM_MUMBLE_PASSWORD" ]; then + command+=( "--password" "$BAM_MUMBLE_PASSWORD" ) +fi + +if [ -n "$BAM_MUMBLE_PORT" ]; then + command+=( "--port" "$BAM_MUMBLE_PORT" ) +fi + +if [ -n "$BAM_USER" ]; then + command+=( "--user" "$BAM_USER" ) +fi + +if [ -n "$BAM_TOKENS" ]; then + command+=( "--tokens" "$BAM_TOKENS" ) +fi + +if [ -n "$BAM_CHANNEL" ]; then + command+=( "--channel" "$BAM_CHANNEL" ) +fi + +if [ -n "$BAM_CERTIFICATE" ]; then + command+=( "--cert" "$BAM_CERTIFICATE" ) +fi + +if [ -n "$BAM_CONFIG_file" ]; then + if [ ! -f "$BAM_CONFIG_file" ]; then + cp "/botamusique/configuration.example.ini" "$BAM_CONFIG_file" + fi + command+=( "--config" "$BAM_CONFIG_file" ) +else + if [ ! -f "/botamusique/configuration.ini" ]; then + cp "/botamusique/configuration.example.ini" "/botamusique/configuration.ini" + fi + command+=( "--config" "/botamusique/configuration.ini" ) +fi + +exec "${command[@]}"