Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Docker build action #8108

Merged
merged 4 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish Docker Image

on: workflow_dispatch
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
submodules: 'true'
fetch-tags: 'true'

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Git Tag Version
id: git_tag_version
run: |
echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV

- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
file: build/docker/build.Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
build-args: |
GIT_BRANCH=${{ github.ref_name }}
GIT_REPO=https://github.com/${{ github.repository }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
37 changes: 37 additions & 0 deletions build/docker/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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/*

# Install Xvfb for headless GUI
RUN apt-get update -y \
&& apt-get -y install \
xvfb nodejs npm git \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

# Set up a user in the container
RUN useradd -ms /bin/bash --home-dir /home/user user
USER user

# Clone the repository with arguments
ARG GIT_REPO=${GIT_REPO:-"https://github.com/tribler/tribler.git"}
ARG GIT_BRANCH=${GIT_BRANCH:-"main"}
RUN echo "Cloning $GIT_REPO on branch $GIT_BRANCH"
RUN git clone --recursive --branch "$GIT_BRANCH" "$GIT_REPO" /home/user/tribler

# Install NPM dependencies
WORKDIR /home/user/tribler/src/tribler/ui
RUN npm install \
&& npm run build

# Install Python dependencies
WORKDIR /home/user/tribler
RUN pip3 install -r requirements.txt

# Set IPv8 on pythonpath
ENV PYTHONPATH=pyipv8

# Run the application using Xvfb
CMD xvfb-run python3 src/run_tribler.py
11 changes: 11 additions & 0 deletions build/docker/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

services:
tribler:
image: ghcr.io/tribler/tribler:latest
network_mode: host
environment:
CORE_API_PORT: 8085
CORE_API_KEY: "changeme"
volumes:
- ~/.Tribler/git:/home/user/.Tribler
- ~/Downloads/TriblerDownloads:/home/user/Downloads/TriblerDownloads