mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-07 02:23:42 +08:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f32d8cbefc | ||
|
|
3e985502c2 | ||
|
|
ad3132e8c2 | ||
|
|
830ace0e47 | ||
|
|
1c36893729 | ||
|
|
a87aaab6f7 | ||
|
|
21699b8960 | ||
|
|
87ee25d404 | ||
|
|
c1714f9e6b | ||
|
|
754765b766 | ||
|
|
419f0cf571 | ||
|
|
55d9ac521f | ||
|
|
3406b3b471 | ||
|
|
f067ad2458 | ||
|
|
7eafd0a969 | ||
|
|
116f30bc0a | ||
|
|
04aa20e836 | ||
|
|
3bf4cc861b | ||
|
|
3c6620a3f9 | ||
|
|
ab0ea5a1d8 | ||
|
|
f894ad2686 | ||
|
|
570340d4e5 | ||
|
|
7dbe706282 | ||
|
|
0c9559f695 | ||
|
|
3113e2b64e | ||
|
|
f0ce992a27 | ||
|
|
6334cfc8bc | ||
|
|
451a569617 | ||
|
|
44d82d6544 |
79
.github/workflows/build.yml
vendored
79
.github/workflows/build.yml
vendored
@@ -13,6 +13,10 @@ on:
|
||||
- '.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
|
||||
@@ -68,34 +67,26 @@ jobs:
|
||||
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
|
||||
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
|
||||
|
||||
17
Dockerfile
17
Dockerfile
@@ -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"]
|
||||
|
||||
@@ -9,6 +9,7 @@ services:
|
||||
RAM_SIZE: "512M"
|
||||
devices:
|
||||
- /dev/kvm
|
||||
- /dev/net/tun
|
||||
- /dev/vhost-net
|
||||
device_cgroup_rules:
|
||||
- 'c *:* rwm'
|
||||
|
||||
63
readme.md
63
readme.md
@@ -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:
|
||||
@@ -85,32 +98,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?
|
||||
|
||||
By default, a single core and 512 MB of RAM are allocated to the container. To increase this, add the following environment variables:
|
||||
@@ -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:
|
||||
@@ -209,6 +185,17 @@ 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.
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
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=$?; } || :
|
||||
(( rc != 0 )) && error "Failed to cpio $RDC, reason $rc" && exit 92
|
||||
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"
|
||||
|
||||
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-"*
|
||||
|
||||
11
src/reset.sh
11
src/reset.sh
@@ -25,15 +25,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
|
||||
|
||||
Reference in New Issue
Block a user