From be0c73967bd93ff5a5cfc99c1cb3a237cf1e660d Mon Sep 17 00:00:00 2001 From: vaporvee Date: Mon, 5 Aug 2024 02:06:37 +0200 Subject: [PATCH] added docker support --- .gitignore | 10 ++++----- build_plugins.py => build.py | 12 +++++++++-- build/.env.example | 7 +++++++ build/Dockerfile | 24 ++++++++++++++++++++++ build/docker-compose.yaml | 39 ++++++++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 8 deletions(-) rename build_plugins.py => build.py (53%) create mode 100644 build/.env.example create mode 100644 build/Dockerfile create mode 100644 build/docker-compose.yaml diff --git a/.gitignore b/.gitignore index 4e0749d..9245447 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,13 @@ .env # Building -acecore -*.exe +acecore* +plugins/ +build/web/ # Logging logs/ # Web web/key.pem -web/cert.pem - -# Custom plugins -plugins/ \ No newline at end of file +web/cert.pem \ No newline at end of file diff --git a/build_plugins.py b/build.py similarity index 53% rename from build_plugins.py rename to build.py index 7164b34..7a1e456 100644 --- a/build_plugins.py +++ b/build.py @@ -1,8 +1,15 @@ import os import subprocess +import shutil + +app_name = 'acecore' src_dir = './plugin_src' -output_dir = './plugins' +output_dir = './build' + +subprocess.run('go build .', shell=True, check=True) +shutil.copy(app_name, output_dir) +print(f'Built main executable in {output_dir}/{app_name}') if not os.path.exists(output_dir): os.makedirs(output_dir) @@ -10,6 +17,7 @@ if not os.path.exists(output_dir): for folder_name in os.listdir(src_dir): folder_path = os.path.join(src_dir, folder_name) if os.path.isdir(folder_path): - command = f'go build -buildmode=plugin -o {output_dir}/{folder_name}.so {folder_path}' + command = f'go build -buildmode=plugin -o {output_dir}/plugins/{folder_name}.so {folder_path}' subprocess.run(command, shell=True, check=True) print(f'Built plugin: {folder_name}.so') + diff --git a/build/.env.example b/build/.env.example new file mode 100644 index 0000000..3a56556 --- /dev/null +++ b/build/.env.example @@ -0,0 +1,7 @@ +BOT_TOKEN= +DB_USER="" +DB_PASSWORD="" +DB_SERVER="" +DB_PORT="" +DB_NAME="" +LOG_WEBHOOK= diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..6e2e727 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:latest + +# Install necessary packages +RUN apt-get update && apt-get install -y \ + postgresql-client \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +# Copy the binary executable and other folders +COPY acecore /app/acecore +COPY plugins/ /app/plugins/ +COPY web/ /app/web/ + +# Set executable permissions +RUN chmod +x /app/acecore + +# Expose the port +EXPOSE 443 + +# Command to start the application +CMD ["/app/acecore"] diff --git a/build/docker-compose.yaml b/build/docker-compose.yaml new file mode 100644 index 0000000..8cefcaf --- /dev/null +++ b/build/docker-compose.yaml @@ -0,0 +1,39 @@ +version: '3.3' + +services: + db: + image: postgres:13 + container_name: acecore_db + environment: + POSTGRES_USER: acecore_prod + POSTGRES_PASSWORD: ${DB_PASSWORD} + POSTGRES_DB: acecore_prod + volumes: + - db_data:/var/lib/postgresql/data + ports: + - "5432:5432" + restart: always + + app: + build: . + container_name: acecore_app + environment: + BOT_TOKEN: ${BOT_TOKEN} + DB_USER: "acecore_prod" + DB_PASSWORD: ${DB_PASSWORD} + DB_SERVER: "db" + DB_PORT: 5432 + DB_NAME: "acecore_prod" + LOG_WEBHOOK: ${LOG_WEBHOOK} + ports: + - "443:443" + depends_on: + - db + volumes: + - ./logs:/app/logs + - ./web:/app/web + - ./plugins:/app/plugins" + restart: always + +volumes: + db_data: