Compare commits

..

30 Commits
v4.32 ... v4.35

Author SHA1 Message Date
Kroese
6218333fec feat: Console mode
* feat: Console mode

* fix: Increase timeout
2023-11-29 20:24:28 +01:00
Kroese
f32d8cbefc feat: Read version from image
feat: Read version from image
2023-11-29 18:13:37 +01:00
Kroese
3e985502c2 docs: Networking 2023-11-29 18:11:19 +01:00
Kroese
ad3132e8c2 docs: Networking 2023-11-29 18:09:02 +01:00
Kroese
830ace0e47 feat: Read version from image 2023-11-29 18:07:41 +01:00
Kroese
1c36893729 build: Set version 2023-11-29 18:05:47 +01:00
Kroese
a87aaab6f7 build: Docker metadata 2023-11-29 18:03:34 +01:00
Kroese
21699b8960 build: Bash
build: Bash
2023-11-29 08:52:15 +01:00
Kroese
87ee25d404 build: Bash 2023-11-29 08:51:52 +01:00
Kroese
c1714f9e6b build: External labels
* build: External labels
2023-11-29 08:26:41 +01:00
Kroese
754765b766 docs: Readme
docs: Readme
2023-11-28 11:51:06 +01:00
Kroese
419f0cf571 docs: Readme 2023-11-28 11:50:47 +01:00
Kroese
55d9ac521f build: Push to mirror
build: Push to mirror
2023-11-26 04:06:16 +01:00
Kroese
3406b3b471 build: Push to mirror 2023-11-26 04:05:58 +01:00
Kroese
f067ad2458 build: Concurrency
build: Concurrency
2023-11-24 04:09:16 +01:00
Kroese
7eafd0a969 build: Concurrency 2023-11-24 04:08:53 +01:00
Kroese
116f30bc0a fix: Cleanup dirs
fix: Cleanup dirs
2023-11-24 01:41:19 +01:00
Kroese
04aa20e836 fix: Cleanup dirs 2023-11-24 01:37:39 +01:00
Kroese
3bf4cc861b docs: Readme
docs: Readme
2023-11-23 21:21:14 +01:00
Kroese
3c6620a3f9 docs: Readme 2023-11-23 21:20:29 +01:00
Kroese
ab0ea5a1d8 docs: Readme
docs: Readme
2023-11-22 19:17:24 +01:00
Kroese
f894ad2686 docs: Readme 2023-11-22 19:16:08 +01:00
Kroese
570340d4e5 fix: Healthcheck start period
fix: Healthcheck start period
2023-11-20 11:46:38 +01:00
Kroese
7dbe706282 fix: Healthcheck start period 2023-11-20 11:45:28 +01:00
Kroese
0c9559f695 fix: Variables
fix: Variables
2023-11-19 20:16:10 +01:00
Kroese
3113e2b64e fix: Variables 2023-11-19 19:56:11 +01:00
Kroese
f0ce992a27 feat: Control device nodes #382
feat: Control device nodes #382
2023-11-17 15:16:36 +01:00
databreach
6334cfc8bc Control device nodes
Add control over whether device nodes are created.
2023-11-17 14:39:53 +01:00
Kroese
451a569617 fix: Remove unused vars
fix: Remove unused vars
2023-11-16 23:28:53 +01:00
Kroese
44d82d6544 fix: Remove unused vars 2023-11-16 23:28:12 +01:00
9 changed files with 103 additions and 113 deletions

View File

@@ -7,12 +7,16 @@ on:
- master
paths-ignore:
- '**/*.md'
- '**/*.yml'
- '**/*.yml'
- '.gitignore'
- '.dockerignore'
- '.github/**'
- '.github/workflows/**'
concurrency:
group: build
cancel-in-progress: false
jobs:
shellcheck:
name: Check
@@ -22,37 +26,32 @@ jobs:
needs: shellcheck
runs-on: ubuntu-latest
permissions:
actions: write
packages: write
contents: read
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Prepare Docker build
id: prepare
run: |
PLATFORMS="linux/amd64,linux/arm64"
VERSION="${{ vars.MAJOR }}.${{ vars.MINOR }}"
TAGS=()
TAGS=("${{ github.repository }}:latest")
TAGS+=("${{ github.repository }}:${VERSION}")
#TAGS+=("${{ secrets.DOCKERHUB_MIRROR }}:latest")
#TAGS+=("${{ secrets.DOCKERHUB_MIRROR }}:${VERSION}")
TAGS+=("ghcr.io/${{ github.repository }}:latest")
TAGS+=("ghcr.io/${{ github.repository }}:${VERSION}")
echo "tags=${TAGS[@]}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "docker_platforms=${PLATFORMS}" >> $GITHUB_OUTPUT
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
context: git
images: |
${{ secrets.DOCKERHUB_REPO }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest,priority=100
type=raw,value=${{ vars.MAJOR }}.${{ vars.MINOR }}
labels: |
org.opencontainers.image.title=${{ vars.NAME }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login into Docker Hub
uses: docker/login-action@v3
@@ -66,36 +65,28 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build Docker image
run: |
TAGS=(${{ steps.prepare.outputs.tags }})
echo "Build date: ${{ steps.prepare.outputs.build_date }}"
echo "Docker platform: ${{ steps.prepare.outputs.docker_platforms }}"
echo "Tags: ${{ steps.prepare.outputs.tags }}"
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
--output "type=image,push=true" \
--progress=plain \
--build-arg "BUILD_ARG=${GITHUB_RUN_ID}" \
--build-arg "VERSION_ARG=${{ steps.prepare.outputs.version }}" \
--build-arg "DATE_ARG=${{ steps.prepare.outputs.build_date }}" \
--build-arg "VCS_REF=${GITHUB_SHA::8}" \
$(printf "%s" "${TAGS[@]/#/ --tag }" ) .
-
name: Clear Docker credentials
run: |
rm -f ${HOME}/.docker/config.json
name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
provenance: false
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.labels }}
build-args: |
VCS_REF=${GITHUB_SHA::8}
VERSION_ARG=${{ steps.meta.outputs.version }}
-
name: Create a release
uses: action-pack/github-release@v2
env:
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
with:
tag: "v${{ steps.prepare.outputs.version }}"
title: "v${{ steps.prepare.outputs.version }}"
tag: "v${{ steps.meta.outputs.version }}"
title: "v${{ steps.meta.outputs.version }}"
-
name: Increment version variable
uses: action-pack/bump@v2

View File

@@ -33,7 +33,7 @@ RUN apt-get update && apt-get -y upgrade && \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY src/*.sh /run/
COPY ./src /run/
COPY --from=builder /qemu-host.bin /run/host.bin
RUN chmod +x /run/*.sh && chmod +x /run/*.bin
@@ -49,20 +49,9 @@ ENV CPU_CORES "1"
ENV DISK_SIZE "16G"
ENV RAM_SIZE "512M"
ARG DATE_ARG=""
ARG BUILD_ARG=0
ARG VERSION_ARG="0.0"
ENV VERSION=$VERSION_ARG
RUN echo "$VERSION_ARG" > /run/version
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.title="Virtual DSM"
LABEL org.opencontainers.image.created=${DATE_ARG}
LABEL org.opencontainers.image.revision=${BUILD_ARG}
LABEL org.opencontainers.image.version=${VERSION_ARG}
LABEL org.opencontainers.image.source="https://github.com/vdsm/virtual-dsm/"
LABEL org.opencontainers.image.url="https://hub.docker.com/r/vdsm/virtual-dsm/"
LABEL org.opencontainers.image.description="Virtual DSM in a docker container"
HEALTHCHECK --interval=60s --retries=2 CMD /run/check.sh
HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]

View File

@@ -9,6 +9,7 @@ services:
RAM_SIZE: "512M"
devices:
- /dev/kvm
- /dev/net/tun
- /dev/vhost-net
device_cgroup_rules:
- 'c *:* rwm'

View File

@@ -10,6 +10,7 @@
[![Pulls]][hub_url]
</div></h1>
Virtual DSM in a docker container.
## Features
@@ -33,7 +34,6 @@ services:
DISK_SIZE: "16G"
devices:
- /dev/kvm
- /dev/vhost-net
cap_add:
- NET_ADMIN
ports:
@@ -74,6 +74,19 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
Replace the example path `/home/user/data` with the desired storage folder.
* ### How do I add multiple disks?
To create additional disks, modify your compose file like this:
```yaml
environment:
DISK2_SIZE: "32G"
DISK3_SIZE: "64G"
volumes:
- /home/example:/storage2
- /mnt/data/example:/storage3
```
* ### How do I change the space reserved by the virtual disk?
By default, the entire disk space is reserved in advance. To create a growable disk that only reserves the space that is actually used, add the following environment variable:
@@ -84,32 +97,6 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```
Keep in mind that this will not affect any of your existing disks, it only applies to newly created disks.
* ### How do I add multiple disks?
To mount extra volumes, modify your compose file like this:
```yaml
environment:
DISK2_SIZE: "32G"
DISK3_SIZE: "64G"
volumes:
- /home/example2:/storage2
- /home/example3:/storage3
```
Additionally, it's also possible to passthrough raw disk devices like this:
```yaml
environment:
DEVICE2: "/dev/vdc1"
DEVICE3: "/dev/vdc2"
devices:
- /dev/vdc1
- /dev/vdc2
```
Please beware that any pre-existing partitions and data on those devices will be wiped.
* ### How do I increase the amount of CPU or RAM?
@@ -185,17 +172,6 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
Please note that even if you don't need DHCP, it's still recommended to enable this feature as it prevents NAT issues and increases performance by using a `macvtap` interface.
* ### How do I install a specific version of vDSM?
By default, version 7.2.1 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows:
```yaml
environment:
URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
```
With this method, it is even possible to switch between different versions while keeping all your file data intact.
* ### How do I passthrough my GPU?
To passthrough your Intel GPU, add the following lines to your compose file:
@@ -208,7 +184,18 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```
This can be used to enable the facial recognition function in Synology Photos for example.
* ### How do I install a specific version of vDSM?
By default, version 7.2.1 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows:
```yaml
environment:
URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
```
With this method, it is even possible to switch between different versions while keeping all your file data intact.
* ### What are the differences compared to the standard DSM?
There are only two minor differences: the Virtual Machine Manager package is not available, and Surveillance Station will not include any free licenses.

View File

@@ -27,9 +27,7 @@ addDisk () {
local GB
local DIR
local REQ
local SIZE
local SPACE
local MIN_SIZE
local CUR_SIZE
local DATA_SIZE
local DISK_ID=$1
@@ -46,8 +44,7 @@ addDisk () {
DISK_SPACE=$(echo "${DISK_SPACE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
DATA_SIZE=$(numfmt --from=iec "${DISK_SPACE}")
MIN_SIZE=6442450944
if (( DATA_SIZE < MIN_SIZE )); then
if (( DATA_SIZE < 6442450944 )); then
error "Please increase ${DISK_DESC^^}_SIZE to at least 6 GB." && exit 83
fi

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -Eeuo pipefail
echo " Starting Virtual DSM for Docker v${VERSION}..."
echo " Starting Virtual DSM for Docker v$(</run/version)..."
echo " For support visit https://github.com/vdsm/virtual-dsm/"
cd /run
@@ -17,6 +17,11 @@ cd /run
trap - ERR
if [[ "${CONSOLE}" == [Yy]* ]]; then
exec qemu-system-x86_64 -pidfile "${QEMU_PID}" ${ARGS:+ $ARGS}
exit $?
fi
set -m
(
[[ "${DEBUG}" == [Yy1]* ]] && info "$VERS" && set -x

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env bash
set -Eeuo pipefail
: ${URL:=''} # URL of the PAT file to be downloaded.
: ${DEV:='Y'} # Controls whether device nodes are created.
if [ -f "$STORAGE"/dsm.ver ]; then
BASE=$(cat "${STORAGE}/dsm.ver")
else
@@ -8,7 +11,6 @@ else
BASE="DSM_VirtualDSM_42962"
fi
: ${URL:=''}
[ -n "$URL" ] && BASE=$(basename "$URL" .pat)
if [[ -f "$STORAGE/$BASE.boot.img" ]] && [[ -f "$STORAGE/$BASE.system.img" ]]; then
@@ -107,8 +109,14 @@ if [ -f "${RDC}" ]; then
{ xz -dc <"$RDC" >"$TMP/rd" 2>/dev/null; rc=$?; } || :
(( rc != 1 )) && error "Failed to unxz $RDC, reason $rc" && exit 91
{ (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || :
(( rc != 0 )) && error "Failed to cpio $RDC, reason $rc" && exit 92
if [[ "${DEV}" == [Nn]* ]]; then
# Exclude dev/ from cpio extract
{ (cd "$TMP" && cpio -it < "$TMP/rd" | grep -Ev 'dev/' | while read -r entry; do cpio -idm "$entry" < "$TMP/rd" 2>/dev/null; done); rc=$?; } || :
else
{ (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || :
fi
(( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92
mkdir -p /run/extract
for file in $TMP/usr/lib/libcurl.so.4 \
@@ -240,7 +248,13 @@ MOUNT="$TMP/system"
rm -rf "$MOUNT" && mkdir -p "$MOUNT"
mv "$HDA.tgz" "$HDA.txz"
tar xpfJ "$HDA.txz" --absolute-names -C "$MOUNT/"
if [[ "${DEV}" == [Nn]* ]]; then
# Exclude dev/ from tar extract
tar xpfJ "$HDA.txz" --absolute-names --exclude="dev" -C "$MOUNT/"
else
tar xpfJ "$HDA.txz" --absolute-names -C "$MOUNT/"
fi
[ -d "$PKG" ] && mv "$PKG/" "$MOUNT/.SynoUpgradePackages/"
rm -f "$MOUNT/.SynoUpgradePackages/ActiveInsight-"*

View File

@@ -12,6 +12,7 @@ trap 'error "Status $? while: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR
: ${GPU:='N'} # Enable GPU passthrough
: ${DEBUG:='N'} # Enable debugging mode
: ${CONSOLE:='N'} # Start in console mode
: ${ALLOCATE:='Y'} # Preallocate diskspace
: ${ARGUMENTS:=''} # Extra QEMU parameters
: ${CPU_CORES:='1'} # Amount of CPU cores
@@ -25,15 +26,20 @@ MINOR=$(uname -r | cut -d '.' -f2)
ARCH=$(dpkg --print-architecture)
VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1)
# Check folder
STORAGE="/storage"
[ ! -d "$STORAGE" ] && error "Storage folder (${STORAGE}) not found!" && exit 13
# Cleanup files
rm -f /run/dsm.url
rm -f /run/qemu.pid
rm -f /run/qemu.count
# Check folder
# Cleanup dirs
STORAGE="/storage"
[ ! -d "$STORAGE" ] && error "Storage folder (${STORAGE}) not found!" && exit 13
rm -rf /tmp/dsm
rm -rf "$STORAGE/tmp"
return 0

View File

@@ -48,7 +48,7 @@ sleep 0.2
while ! nc -z -w1 127.0.0.1 2210 > /dev/null 2>&1; do
sleep 0.1
cnt=$((cnt + 1))
(( cnt > 20 )) && error "Failed to connect to qemu-host.." && exit 58
(( cnt > 50 )) && error "Failed to connect to qemu-host.." && exit 58
done
cnt=0
@@ -56,7 +56,7 @@ cnt=0
while ! nc -z -w1 127.0.0.1 12345 > /dev/null 2>&1; do
sleep 0.1
cnt=$((cnt + 1))
(( cnt > 20 )) && error "Failed to connect to qemu-host.." && exit 59
(( cnt > 50 )) && error "Failed to connect to qemu-host.." && exit 59
done
# Configure serial ports