Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
feat: First version (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
lholota authored Aug 1, 2022
1 parent 13de01f commit 999349d
Show file tree
Hide file tree
Showing 15 changed files with 2,981 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"env": {
"test": {
"plugins": [
"@babel/plugin-transform-modules-commonjs"
]
}
}
}
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto
*.sh eol=lf
*.yml eol=lf
root/** eol=lf
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2
updates:
- package-ecosystem: docker
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- dependencies
commit-message:
prefix: fix
include: scope
- package-ecosystem: gradle
directory: "/tests"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- dependencies
commit-message:
prefix: chore
include: scope
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- dependencies
commit-message:
prefix: ci
include: scope
11 changes: 11 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
titleOnly: true
types:
- feat
- fix
- docs
- refactor
- test
- build
- ci
- chore
- revert
23 changes: 23 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI/CD
on:
push:

env:
DEBUG: testcontainers:containers

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # To add version tags
packages: write # To push docker image
issues: write # Semantic release to link issues
steps:
- uses: actions/checkout@master

- uses: homecentr/action-build-docker-image@master
with:
imageName: "homecentr/qbittorrent"
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
dockerHubUserName: ${{ secrets.DOCKERHUB_USERNAME }}
dockerHubPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"node_modules": true
}
}
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM linuxserver/qbittorrent:4.4.3

ARG USER_UID=1000
ARG USER_GID=1000

COPY ./root/ /

RUN mkdir -p /downloads && \
rm -rf /etc/cont-init.d && \
rm -rf /etc/services.d && \
deluser guest && \
deluser abc && \
delgroup users && \
addgroup --gid ${USER_GID} nonroot && \
adduser -u ${USER_UID} -G nonroot -D -H -g "" nonroot && \
chown ${USER_UID} /config && \
chgrp ${USER_GID} /config && \
chown ${USER_UID} /downloads && \
chgrp ${USER_GID} /downloads && \
chown -R ${USER_UID} /defaults && \
chgrp -R ${USER_GID} /defaults && \
chmod a+x /entrypoint.sh && \
echo "WebUI\AuthSubnetWhitelistEnabled=true" >> /defaults/qBittorrent.conf && \
echo "WebUI\AuthSubnetWhitelist=0.0.0.0/0" >> /defaults/qBittorrent.conf

EXPOSE 8080
VOLUME "/config"
VOLUME "/downloads"

USER 1000:1000

ENTRYPOINT [ "ash", "entrypoint.sh" ]
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[![Project status](https://badgen.net/badge/project%20status/stable%20%26%20actively%20maintaned?color=green)](https://github.com/homecentr/docker-qbittorrent/graphs/commit-activity) [![](https://badgen.net/github/label-issues/homecentr/docker-qbittorrent/bug?label=open%20bugs&color=green)](https://github.com/homecentr/docker-qbittorrent/labels/bug) [![](https://badgen.net/github/release/homecentr/docker-qbittorrent)](https://hub.docker.com/repository/docker/homecentr/qbittorrent)
[![](https://badgen.net/docker/pulls/homecentr/qbittorrent)](https://hub.docker.com/repository/docker/homecentr/qbittorrent)
[![](https://badgen.net/docker/size/homecentr/qbittorrent)](https://hub.docker.com/repository/docker/homecentr/qbittorrent)

[![CI/CD](https://github.com/homecentr/docker-qbittorrent/actions/workflows/ci_cd.yml/badge.svg)](https://github.com/homecentr/docker-qbittorrent/actions/workflows/ci_cd.yml)


# Homecentr - qbittorrent
Docker image of qBittorrent based on [LinuxServer.io's image](https://fleet.linuxserver.io/image?name=linuxserver/qbittorrent) just with removed bells and whistles which I do not consider secure - LSIO requires SET_UID, SET_GID and other capabilities. It also generally relies on running as root which I am not comfortable with and therefore this image runs strictly as a non-root user.

## Exposed ports

| Port | Protocol | Description |
|------|------|-------------|
| 8080 | TCP | WebUI |

## Volumes

| Container path | Description |
|------------|---------------|
| /config | qBittorrent configuration and state |
| /downloads | Downloaded files from the torrents |

## Security
The container is regularly scanned for vulnerabilities and updated. Further info can be found in the [Security tab](https://github.com/homecentr/docker-qbittorrent/security).

### Container user
The container uses UID:GID of 1000:1000 by default. Image must be rebuilt in case you need to use a different UID or GID due to file permissions.
15 changes: 15 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Security policy

## Disclosure policy

In case you find a security issues with this docker image, please reach out to me at security@homecentr.io and provide 5 business days to release a fixed version.

## Security update policy

Known security issues will be published in GitHub repository's Security / Security advisories.

## Automated processes

The Docker image is regularly scanned for vulnerabilities with [Snyk.io](https://snyk.io/).

The dependencies are automatically scanned using [Dependabot](https://dependabot.com/). Dependencies are regularly updated. You can check for pending dependency updates by listing open Pull requests with the "dependencies" label.
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.9"
services:
image:
build: .
image: homecentr/qbittorrent:preview
ports:
- "8080:8080"
tmpfs:
- /config:mode=770,uid=1000,gid=1000
- /downloads:mode=770,uid=1000,gid=1000
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@homecentr/qbittorrent",
"version": "1.0.0",
"description": "",
"author": "Lukas Holota",
"license": "MIT",
"scripts": {
"build": "docker-compose build",
"start": "docker-compose up",
"start:shell": "docker-compose run --user=0:0 --entrypoint ash image",
"test": "jest --testTimeout=60000",
"push:preview": "docker-compose push image"
},
"release": {
"branches": [
"master"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
"axios": "^0.27.2",
"cross-env": "^7.0.3",
"jest": "^28.1.3",
"testcontainers": "^8.12.0"
}
}
12 changes: 12 additions & 0 deletions root/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env ash

# Ensure the config directory exists
mkdir -p /config/qBittorrent

# Copy default config if none exists
if [[ ! -e /config/qBittorrent/qBittorrent.conf ]]
then
cp /defaults/qBittorrent.conf /config/qBittorrent/qBittorrent.conf
fi

/usr/bin/qbittorrent-nox --webui-port=8080
33 changes: 33 additions & 0 deletions tests/container.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const path = require("path");
const axios = require("axios");
const { DockerComposeEnvironment } = require("testcontainers");

describe("qBittorrent container should", () => {
var container;
var composeEnvironment;

beforeAll(async () => {
const composeFilePath = path.resolve(__dirname, "..");

composeEnvironment = await new DockerComposeEnvironment(composeFilePath, "docker-compose.yml")
.withBuild()
.up();

container = composeEnvironment.getContainer("image_1");
});

afterAll(async () => {
await composeEnvironment.down();
});

it("Listen on configured port", async () => {
// Arrange
const url = `http://localhost:${container.getMappedPort(8080)}/`

// Act
const response = await axios.get(url);

// Assert
expect(response.status).toBe(200);
});
});
Loading

0 comments on commit 999349d

Please sign in to comment.