Skip to content

Commit

Permalink
Rebase to 3.21
Browse files Browse the repository at this point in the history
  • Loading branch information
thespad committed Feb 4, 2025
1 parent 07698fb commit 90029bb
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

FROM ghcr.io/linuxserver/baseimage-alpine:3.19
FROM ghcr.io/linuxserver/baseimage-alpine:3.21

# set version label
ARG BUILD_DATE
Expand All @@ -17,7 +17,7 @@ ENV PYTHONIOENCODING=utf-8 \
VIRTUAL_ENV=/pyenv \
PATH="/pyenv/bin:$PATH"

RUN \
RUN --mount=type=bind,source=/patch,target=/patch \
apk add --no-cache --update --virtual=build-dependencies \
build-base \
git \
Expand All @@ -34,7 +34,9 @@ RUN \
setuptools \
wheel && \
pip install -U --no-cache-dir pytz && \
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.19 -r /home/py-kms/requirements.txt && \
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.21 -r /home/py-kms/requirements.txt && \
patch /home/py-kms/pykms_PidGenerator.py < /patch/pykms_PidGenerator.patch && \
patch /home/py-kms/KmsDataBase.xml < /patch/KmsDataBase.patch && \
printf "Version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \
apk del --purge \
build-dependencies && \
Expand Down
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,22 @@ The architectures supported by this image are:

More info at [py-kms](https://github.com/Py-KMS-Organization/py-kms).

## Read-Only Operation

This image can be run with a read-only container filesystem.

Running the container read-only requires mounting `/run` to tmpfs with the `exec` flag.

## Non-Root Operation

This image can be run with a non-root user.

## Usage

Here are some example snippets to help you get started creating a container.

### docker-compose ([recommended](https://docs.linuxserver.io/general/docker-compose))

Compatible with docker-compose v2 schemas.

```yaml
---
services:
Expand Down Expand Up @@ -104,12 +112,55 @@ In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as bel
* Shell access whilst the container is running: `docker exec -it py-kms /bin/bash`
* To monitor the logs of the container in realtime: `docker logs -f py-kms`

## Updating Info

Most of our images are static, versioned, and require an image update and container recreation to update the app inside. We do not recommend or support updating apps inside the container. Please consult the [Application Setup](#application-setup) section above to see if it is recommended for the image.

Below are the instructions for updating containers:

### Via Docker Compose

* Update all images: `docker-compose pull`
* or update a single image: `docker-compose pull py-kms`
* Let compose update all containers as necessary: `docker-compose up -d`
* or update a single container: `docker-compose up -d py-kms`
* You can also remove the old dangling images: `docker image prune`

### Via Docker Run

* Update the image: `docker pull ghcr.io/thespad/py-kms`
* Stop the running container: `docker stop py-kms`
* Delete the container: `docker rm py-kms`
* Recreate a new container with the same docker run parameters as instructed above (if mapped correctly to a host folder, your `/config` folder and settings will be preserved)
* You can also remove the old dangling images: `docker image prune`

### Image Update Notifications - Diun (Docker Image Update Notifier)

* We recommend [Diun](https://crazymax.dev/diun/) for update notifications. Other tools that automatically update containers unattended are not recommended or supported.
>[!TIP]
>We recommend [Diun](https://crazymax.dev/diun/) for update notifications. Other tools that automatically update containers unattended are not recommended or supported.
## Building locally

If you want to make local modifications to these images for development purposes or just to customize the logic:

```shell
git clone https://github.com/thespad/docker-py-kms.git
cd docker-py-kms
docker build \
--no-cache \
--pull \
-t ghcr.io/thespad/py-kms:latest .
```

The arm variants can be built on x86_64 hardware and vice versa using `lscr.io/linuxserver/qemu-static`

```bash
docker run --rm --privileged lscr.io/linuxserver/qemu-static --reset
```

## Versions

* **02.02.25:** - Rebase to Alpine 3.21. Patch support for Python 3.21.
* **13.11.24:** - Revert to Alpine 3.19 & Python 3.11 to fix bug with Win 11 and Office activations.
* **26.05.24:** - Rebase to Alpine 3.20.
* **30.12.23:** - Rebase to Alpine 3.19.
Expand Down
47 changes: 47 additions & 0 deletions patch/KmsDataBase.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--- KmsDataBase.xml 2025-02-02 14:24:00.000000000 +0000
+++ KmsDataBase.xml_new.xml 2025-02-02 14:31:01.359088569 +0000
@@ -103,10 +103,22 @@
<Activate KmsItem="7ba0bf23-d0f5-4072-91d9-d55af5a481b6" />
</CsvlkItem>

- <CsvlkItem DisplayName="Windows Server 2022" VlmcsdIndex="0" GroupId="206" MinKeyId="551000000" MaxKeyId="570999999" IniFileName="Windows" EPid="06401-00206-566-174993-03-1033-9600.0000-2802018" Id="ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03" InvalidWinBuild="[0,1,2]">
+ <CsvlkItem DisplayName="Windows Server 2025 Datacenter" VlmcsdIndex="0" GroupId="206" MinKeyId="551000000" MaxKeyId="570999999" IniFileName="Windows" Id="c052f164-cdf6-409a-a0cb-853ba0f0f55a" InvalidWinBuild="[0,1,2]">
+ <Activate KmsItem="c052f164-cdf6-409a-a0cb-853ba0f0f55a" />
+ </CsvlkItem>
+
+ <CsvlkItem DisplayName="Windows Server 2025 Standard" VlmcsdIndex="0" GroupId="206" MinKeyId="551000000" MaxKeyId="570999999" IniFileName="Windows" Id="7dc26449-db21-4e09-ba37-28f2958506a6" InvalidWinBuild="[0,1,2]">
+ <Activate KmsItem="7dc26449-db21-4e09-ba37-28f2958506a6" />
+ </CsvlkItem>
+
+ <CsvlkItem DisplayName="Windows Server 2022 Datacenter" VlmcsdIndex="0" GroupId="206" MinKeyId="551000000" MaxKeyId="570999999" IniFileName="Windows" Id="ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03" InvalidWinBuild="[0,1,2]">
<Activate KmsItem="ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03" />
</CsvlkItem>

+ <CsvlkItem DisplayName="Windows Server 2022 Standard" VlmcsdIndex="0" GroupId="206" MinKeyId="551000000" MaxKeyId="570999999" IniFileName="Windows" Id="de32eafd-aaee-4662-9444-c1befb41bde2" InvalidWinBuild="[0,1,2]">
+ <Activate KmsItem="de32eafd-aaee-4662-9444-c1befb41bde2" />
+ </CsvlkItem>
+
<CsvlkItem DisplayName="Windows Server 2019" VlmcsdIndex="0" GroupId="206" MinKeyId="551000000" MaxKeyId="570999999" IniFileName="Windows" EPid="06401-00206-566-174993-03-1033-9600.0000-2802018" Id="2e7a9ad1-a849-4b56-babe-17d5a29fe4b4" InvalidWinBuild="[0,1,2]">
<Activate KmsItem="58e2134f-8e11-4d17-9cb2-91069c151148" />
<Activate KmsItem="7fde5219-fbfa-484a-82c9-34d1ad53e856" />
@@ -568,8 +580,19 @@

<AppItem DisplayName="Windows" VlmcsdIndex="0" Id="55c92734-d682-4d71-983e-d6ec3f16059f" MinActiveClients="50">

- <KmsItem DisplayName="Windows Server 2022" Id="ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03" DefaultKmsProtocol="6.0" NCountPolicy="5">
+ <KmsItem DisplayName="Windows Server 2025 Datacenter" Id="c052f164-cdf6-409a-a0cb-853ba0f0f55a" DefaultKmsProtocol="6.0" NCountPolicy="5">
+ <SkuItem DisplayName="Windows Server 2025 Datacenter" Id="c052f164-cdf6-409a-a0cb-853ba0f0f55a" Gvlk="D764K-2NDRG-47T6Q-P8T8W-YP6DF" />
+ </KmsItem>
+
+ <KmsItem DisplayName="Windows Server 2025 Standard" Id="7dc26449-db21-4e09-ba37-28f2958506a6" DefaultKmsProtocol="6.0" NCountPolicy="5">
+ <SkuItem DisplayName="Windows Server 2025 Standard" Id="7dc26449-db21-4e09-ba37-28f2958506a6" Gvlk="TVRH6-WHNXV-R9WG3-9XRFY-MY832" />
+ </KmsItem>
+
+ <KmsItem DisplayName="Windows Server 2022 Datacenter" Id="ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03" DefaultKmsProtocol="6.0" NCountPolicy="5">
<SkuItem DisplayName="Windows Server 2022 Datacenter" Id="ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03" Gvlk="WX4NM-KYWYW-QJJR4-XV3QB-6VM33" />
+ </KmsItem>
+
+ <KmsItem DisplayName="Windows Server 2022 Standard" Id="de32eafd-aaee-4662-9444-c1befb41bde2" DefaultKmsProtocol="6.0" NCountPolicy="5">
<SkuItem DisplayName="Windows Server 2022 Standard" Id="de32eafd-aaee-4662-9444-c1befb41bde2" Gvlk="VDYBN-27WPP-V4HQT-9VMD4-VMK7H" />
</KmsItem>

10 changes: 10 additions & 0 deletions patch/pykms_PidGenerator.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- /home/py-kms/pykms_PidGenerator.py
+++ /home/py-kms/pykms_PidGenerator_patched.py
@@ -59,7 +59,7 @@
minTime = datetime.date(d.year, d.month, d.day)

# Generate Year and Day Number
- randomDate = datetime.date.fromtimestamp(random.randint(time.mktime(minTime.timetuple()), time.mktime(datetime.datetime.now().timetuple())))
+ randomDate = datetime.date.fromtimestamp(random.randint(int(time.mktime(minTime.timetuple())), int(time.mktime(datetime.datetime.now().timetuple()))))
firstOfYear = datetime.date(randomDate.year, 1, 1)
randomDayNumber = int((time.mktime(randomDate.timetuple()) - time.mktime(firstOfYear.timetuple())) / 86400 + 0.5)

0 comments on commit 90029bb

Please sign in to comment.