From 197605c23c18fd474617a33cd5226e0665964505 Mon Sep 17 00:00:00 2001 From: Quinten Stokkink Date: Thu, 22 Aug 2024 10:57:26 +0200 Subject: [PATCH] Added Docker build action --- .github/workflows/build_docker.yml | 21 ++++++++++++++ build/docker/build.Dockerfile | 33 ++++++++++++++++++++++ build/docker/build.Dockerfile.dockerignore | 22 +++++++++++++++ build/docker/configuration.json | 28 ++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 .github/workflows/build_docker.yml create mode 100644 build/docker/build.Dockerfile create mode 100644 build/docker/build.Dockerfile.dockerignore create mode 100644 build/docker/configuration.json diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml new file mode 100644 index 0000000000..b5bab40108 --- /dev/null +++ b/.github/workflows/build_docker.yml @@ -0,0 +1,21 @@ +name: docker-build + +on: workflow_dispatch + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and export + uses: docker/build-push-action@v6 + with: + tags: tribler:latest + outputs: type=docker,dest=/tmp/myimage.tar + file: build/docker/build.Dockerfile + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: myimage + path: /tmp/myimage.tar diff --git a/build/docker/build.Dockerfile b/build/docker/build.Dockerfile new file mode 100644 index 0000000000..20179c627a --- /dev/null +++ b/build/docker/build.Dockerfile @@ -0,0 +1,33 @@ +# libtorrent-1.2.19 does not support python 3.11 yet +FROM python:3.10-slim + +RUN apt-get update \ + && apt-get install -y --no-install-recommends libsodium23=1.0.18-1 \ + && rm -rf /var/lib/apt/lists/* + +# Then, install pip dependencies so that it can be cached and does not +# need to be built every time the source code changes. +# This reduces the docker build time. +COPY ./requirements.txt /app/tribler/requirements.txt +RUN pip3 install -r /app/tribler/requirements.txt + +RUN useradd -ms /bin/bash user + +# Create default state and download directories and set the permissions +RUN chown -R user:user /app +RUN mkdir /state /downloads && chown -R user:user /state /downloads + +# Copy the source code and set the working directory +COPY ./src /app/tribler/src/ +WORKDIR /app/tribler/ + +ENV CORE_API_PORT=20100 +ENV TSTATEDIR=/state + +VOLUME /state +VOLUME /downloads +COPY ./build/docker/configuration.json /state/git/configuration.json + +USER user + +CMD exec python3 /app/tribler/src/run_tribler.py diff --git a/build/docker/build.Dockerfile.dockerignore b/build/docker/build.Dockerfile.dockerignore new file mode 100644 index 0000000000..44dacac416 --- /dev/null +++ b/build/docker/build.Dockerfile.dockerignore @@ -0,0 +1,22 @@ +.* +build +doc +scripts + +src/run_unit_tests.py +src/tribler/test_integration +src/tribler/test_unit + +pyipv8/.* +pyipv8/*.md +pyipv8/*.ini +pyipv8/create_setup_taskmanager.py +pyipv8/create_test_coverage_report.py +pyipv8/github_increment_version.py +pyipv8/run_all_tests.py +pyipv8/setup.py +pyipv8/doc +pyipv8/scripts +pyipv8/stresstest +pyipv8/systemd +pyipv8/ipv8/test diff --git a/build/docker/configuration.json b/build/docker/configuration.json new file mode 100644 index 0000000000..a5817308d4 --- /dev/null +++ b/build/docker/configuration.json @@ -0,0 +1,28 @@ +{ + "api": { + "http_host": "127.0.0.1", + "https_host": "127.0.0.1" + }, + "ipv8": { + "interfaces": [ + { + "interface": "UDPIPv4", + "ip": "0.0.0.0", + "port": 7759, + "worker_threads": 8 + }, + { + "interface": "UDPIPv6", + "ip": "::", + "port": 7760 + } + ] + }, + "libtorrent": { + "port": 0, + "download_defaults": { + "saveas": "/downloads" + } + }, + "state_dir": "/state" +} \ No newline at end of file