Skip to content

Commit

Permalink
Added Docker build action (#8108)
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink authored Sep 2, 2024
2 parents 7381622 + 134fa64 commit b053617
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
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

0 comments on commit b053617

Please sign in to comment.