From 4ff72021cbe284a6f5141ebda0dcd24b9650074c Mon Sep 17 00:00:00 2001 From: hikariatama Date: Sun, 20 Nov 2022 17:54:26 +0000 Subject: [PATCH] 1.6.0 - Update dockerfile [test] --- Dockerfile | 15 +++++++++---- docker-compose.yml | 11 ++++++++-- docker.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 docker.sh diff --git a/Dockerfile b/Dockerfile index d0ed7a0..f84ad5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,19 @@ -FROM python:3.8-slim-buster as main +FROM python:3.8-slim as python-base ENV DOCKER=true ENV GIT_PYTHON_REFRESH=quiet -ENV PIP_NO_CACHE_DIR=1 -RUN apt update && apt install libcairo2 git -y --no-install-recommends + +ENV PIP_NO_CACHE_DIR=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 + +RUN apt update && apt install libcairo2 git build-essential -y --no-install-recommends RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives /tmp/* RUN git clone https://github.com/hikariatama/Hikka /Hikka + WORKDIR /Hikka RUN pip install --no-warn-script-location --no-cache-dir -r requirements.txt + EXPOSE 8080 RUN mkdir /data -CMD ["python3", "-m", "hikka"] + +CMD python -m hikka diff --git a/docker-compose.yml b/docker-compose.yml index 3f08c06..51a4a74 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,16 @@ version: "3" services: worker: - build: . + container_name: "hikka-worker" + build: + context: . volumes: - worker:/data - + stop_signal: SIGINT + restart: unless-stopped + command: "python -m hikka" + ports: + - "${EXTERNAL_PORT:-8080}:8080" + volumes: worker: diff --git a/docker.sh b/docker.sh new file mode 100644 index 0000000..7c758a2 --- /dev/null +++ b/docker.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +PORT=3429 # Port to run the server on +echo "EXTERNAL_PORT=$PORT" >.env + +if ! [ -x "$(command -v docker)" ]; then + printf "\033[0;34mInstalling docker...\e[0m" + if [ -f /etc/debian_version ]; then + sudo apt-get install \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg-agent \ + software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" + sudo apt-get update + sudo apt-get install docker-ce docker-ce-cli containerd.io + elif [ -f /etc/arch-release ]; then + sudo pacman -Syu docker + elif [ -f /etc/redhat-release ]; then + sudo yum install -y yum-utils + sudo yum-config-manager \ + --add-repo \ + https://download.docker.com/linux/centos/docker-ce.repo + sudo yum install docker-ce docker-ce-cli containerd.io + fi + printf "\033[0;32m - success\e[0m\n" +else + printf "\033[0;32mDocker is already installed\e[0m\n" +fi + +printf "\033[0;34mDownloading configuration files...\e[0m" +if [ -f "Dockerfile" ]; then + rm Dockerfile +fi +wget -q https://github.com/hikariatama/Hikka/raw/master/Dockerfile +if [ -f "docker-compose.yml" ]; then + rm docker-compose.yml +fi +wget -q https://github.com/hikariatama/Hikka/raw/master/docker-compose.yml +printf "\033[0;32m - success\e[0m\n" + +printf "\033[0;34mBuilding docker image...\e[0m" +docker-compose up -d --build 1>/dev/null 2>&1 +printf "\033[0;32m - success\e[0m\n" + +printf "\033[0;32mFollow this url to continue installation:\e[0m\n" +ssh "-o StrictHostKeyChecking=no" "-R 80:127.0.0.1:$PORT" "nokey@localhost.run" 2>&1 | grep "tunneled"