Skip to content

Commit a838903

Browse files
committed
Merge branch 'feat/acl'
2 parents 3c00232 + 998d3c2 commit a838903

17 files changed

Lines changed: 744 additions & 98 deletions

File tree

.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Git files
2+
.git
3+
.gitignore
4+
.github
5+
6+
# Documentation
7+
*.md
8+
*.exe
9+
10+
docker-compose.windows.yml
11+
docker-compose.yml
12+
Dockerfile
13+
Dockerfile.ci
14+
Dockerfile.windows

.github/workflows/release_docker.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ concurrency:
2424
cancel-in-progress: true
2525

2626
env:
27-
DOCKERHUB_ORG_NAME: ${{ vars.DOCKERHUB_ORG_NAME || 'openlistteam' }}
2827
GHCR_ORG_NAME: ${{ vars.GHCR_ORG_NAME || 'openlistteam' }}
29-
IMAGE_NAME: openlist-git
30-
IMAGE_NAME_DOCKERHUB: openlist
28+
IMAGE_NAME: openlist
3129
REGISTRY: ghcr.io
3230
ARTIFACT_NAME: 'binaries_docker_release'
3331
ARTIFACT_NAME_LITE: 'binaries_docker_release_lite'
@@ -166,20 +164,12 @@ jobs:
166164
username: ${{ github.actor }}
167165
password: ${{ secrets.GITHUB_TOKEN }}
168166

169-
- name: Login to DockerHub Container Registry
170-
if: env.IMAGE_PUSH == 'true'
171-
uses: docker/login-action@v3
172-
with:
173-
username: ${{ vars.DOCKERHUB_ORG_NAME_BACKUP || env.DOCKERHUB_ORG_NAME }}
174-
password: ${{ secrets.DOCKERHUB_TOKEN }}
175-
176167
- name: Docker meta
177168
id: meta
178169
uses: docker/metadata-action@v5
179170
with:
180171
images: |
181172
${{ env.REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}
182-
${{ env.DOCKERHUB_ORG_NAME }}/${{ env.IMAGE_NAME_DOCKERHUB }}
183173
tags: >
184174
${{ github.event_name == 'workflow_dispatch'
185175
&& format('type=raw,value={0}', github.event.inputs.manual_tag)
@@ -250,20 +240,12 @@ jobs:
250240
username: ${{ github.actor }}
251241
password: ${{ secrets.GITHUB_TOKEN }}
252242

253-
- name: Login to DockerHub Container Registry
254-
if: env.IMAGE_PUSH == 'true'
255-
uses: docker/login-action@v3
256-
with:
257-
username: ${{ vars.DOCKERHUB_ORG_NAME_BACKUP || env.DOCKERHUB_ORG_NAME }}
258-
password: ${{ secrets.DOCKERHUB_TOKEN }}
259-
260243
- name: Docker meta
261244
id: meta
262245
uses: docker/metadata-action@v5
263246
with:
264247
images: |
265248
${{ env.REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}
266-
${{ env.DOCKERHUB_ORG_NAME }}/${{ env.IMAGE_NAME_DOCKERHUB }}
267249
tags: >
268250
${{ github.event_name == 'workflow_dispatch'
269251
&& format('type=raw,value={0}', github.event.inputs.manual_tag)
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Release builds (Docker) (Windows Container)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
manual_tag:
7+
description: "Tag name (like v0.1.0). Required if as_latest is true."
8+
required: false
9+
type: string
10+
as_latest:
11+
description: "Tag as latest?"
12+
required: true
13+
default: "false"
14+
type: choice
15+
options:
16+
- "true"
17+
- "false"
18+
windows_version:
19+
description: "Windows Server version"
20+
required: true
21+
default: "ltsc2025"
22+
type: choice
23+
options:
24+
- "ltsc2025"
25+
- "ltsc2022"
26+
- "ltsc2019"
27+
push:
28+
tags:
29+
- "v*"
30+
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
33+
cancel-in-progress: true
34+
35+
env:
36+
GHCR_ORG_NAME: ${{ vars.GHCR_ORG_NAME || 'openlistteam' }}
37+
IMAGE_NAME: openlist
38+
REGISTRY: ghcr.io
39+
IMAGE_PUSH: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
40+
41+
permissions:
42+
packages: write
43+
44+
jobs:
45+
release_docker_windows:
46+
name: Release Windows Docker image
47+
runs-on: windows-2022
48+
strategy:
49+
matrix:
50+
windows_version: ["ltsc2025", "ltsc2022", "ltsc2019"]
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
57+
58+
- name: Login to GitHub Container Registry
59+
if: env.IMAGE_PUSH == 'true'
60+
uses: docker/login-action@v3
61+
with:
62+
registry: ${{ env.REGISTRY }}
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Determine tag
67+
id: tag
68+
shell: pwsh
69+
run: |
70+
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
71+
$tag = "${{ github.event.inputs.manual_tag }}"
72+
$windowsVersion = "${{ github.event.inputs.windows_version }}"
73+
} else {
74+
$tag = "${{ github.ref_name }}"
75+
$windowsVersion = "${{ matrix.windows_version }}"
76+
}
77+
78+
$isLatest = "${{ github.event_name == 'push' || github.event.inputs.as_latest == 'true' }}"
79+
80+
echo "tag=$tag" >> $env:GITHUB_OUTPUT
81+
echo "windows_version=$windowsVersion" >> $env:GITHUB_OUTPUT
82+
echo "is_latest=$isLatest" >> $env:GITHUB_OUTPUT
83+
84+
- name: Build Docker tags
85+
id: meta
86+
shell: pwsh
87+
run: |
88+
$tag = "${{ steps.tag.outputs.tag }}"
89+
$winVer = "${{ steps.tag.outputs.windows_version }}"
90+
$isLatest = "${{ steps.tag.outputs.is_latest }}"
91+
92+
$ghcrImage = "${{ env.REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}"
93+
94+
$tags = @(
95+
"${ghcrImage}:${tag}-windows-${winVer}",
96+
)
97+
98+
if ($isLatest -eq "true") {
99+
$tags += "${ghcrImage}:windows-${winVer}"
100+
if ($winVer -eq "ltsc2025") {
101+
$tags += "${ghcrImage}:windows"
102+
}
103+
}
104+
105+
$tagsString = $tags -join ","
106+
echo "tags=$tagsString" >> $env:GITHUB_OUTPUT
107+
Write-Host "Tags: $tagsString"
108+
109+
- name: Build and push Windows container
110+
shell: pwsh
111+
run: |
112+
$tags = "${{ steps.meta.outputs.tags }}".Split(",")
113+
$tagArgs = @()
114+
foreach ($tag in $tags) {
115+
$tagArgs += "-t"
116+
$tagArgs += $tag.Trim()
117+
}
118+
119+
docker build `
120+
--build-arg WINDOWS_VERSION=${{ steps.tag.outputs.windows_version }} `
121+
-f Dockerfile.windows `
122+
$tagArgs `
123+
.
124+
125+
if ("${{ env.IMAGE_PUSH }}" -eq "true") {
126+
foreach ($tag in $tags) {
127+
Write-Host "Pushing $($tag.Trim())"
128+
docker push $tag.Trim()
129+
}
130+
}

Dockerfile.windows

Lines changed: 87 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,114 @@
1-
# escape=`
2-
# Windows-based Dockerfile for OpenList
3-
# Build stage using official Golang image
4-
# Runtime stage using Windows Server Nano
1+
ARG WINDOWS_VERSION=ltsc2022
2+
FROM mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION} AS frontend
3+
# Use PowerShell as the default shell
4+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
5+
WORKDIR C:/app/frontend
6+
# Install Node.js
7+
RUN Invoke-WebRequest -Uri https://nodejs.org/dist/v25.1.0/node-v25.1.0-x64.msi -OutFile C:/nodejs.msi
8+
RUN Start-Process msiexec.exe -ArgumentList '/i C:\\nodejs.msi /quiet /norestart' -Wait
9+
RUN Remove-Item C:/nodejs.msi -Force
10+
RUN node --version
11+
# Install Git
12+
RUN Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.51.2.windows.1/Git-2.51.2-64-bit.exe -OutFile C:/gitinstaller.exe
13+
RUN Start-Process -FilePath "C:/gitinstaller.exe" -ArgumentList '/VERYSILENT', '/NORESTART', '/NOCANCEL', '/SP-', '/CLOSEAPPLICATIONS' -Wait
14+
RUN Remove-Item C:/gitinstaller.exe -Force
15+
RUN git --version
16+
# Install pnpm
17+
RUN npm install -g pnpm
18+
# Clone the frontend source code
19+
RUN git clone --depth 1 --branch main https://github.com/nbtca/OpenList-Frontend
20+
21+
# Install frontend dependencies and build
22+
WORKDIR C:/app/frontend/OpenList-Frontend
23+
RUN pnpm install
24+
RUN pnpm run build
25+
526

627
# Build stage
7-
FROM golang:1.25.3-windowsservercore-ltsc2025 AS builder
28+
FROM golang:1.25-windowsservercore-${WINDOWS_VERSION} AS builder
829

930
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
1031

1132
WORKDIR C:/app
1233

13-
# 安装 7-Zip
14-
RUN Invoke-WebRequest -Uri https://www.7-zip.org/a/7z2501-x64.msi -OutFile C:\7zip.msi
15-
RUN Start-Process msiexec.exe -ArgumentList '/i C:\7zip.msi /quiet /norestart' -Wait
16-
RUN Remove-Item C:\7zip.msi -Force
17-
18-
# Install MinGW-w64 for CGO support
19-
RUN Invoke-WebRequest -Uri https://github.com/niXman/mingw-builds-binaries/releases/download/15.2.0-rt_v13-rev0/x86_64-15.2.0-release-posix-seh-msvcrt-rt_v13-rev0.7z -OutFile C:/mingw.7z
20-
# Extract to C:\
21-
RUN & 'C:\Program Files\7-Zip\7z.exe' x C:/mingw.7z -oC:\ -y
22-
RUN Remove-Item C:/mingw.7z -Force
23-
24-
# The archive extracts to a folder like C:\mingw64 or C:\x86_64-*\mingw64
25-
# Find the actual mingw64 location and rename/move it to C:\mingw64 if needed
26-
RUN $mingwPath = Get-ChildItem C:\ -Directory | Where-Object { $_.Name -like 'x86_64*' -or $_.Name -eq 'mingw64' } | Select-Object -First 1; `
27-
if ($mingwPath -and $mingwPath.Name -ne 'mingw64') { `
28-
Write-Host "Found MinGW at: $($mingwPath.FullName)"; `
29-
if (Test-Path "$($mingwPath.FullName)\mingw64") { `
30-
Write-Host "Moving nested mingw64 to C:\mingw64"; `
31-
Move-Item "$($mingwPath.FullName)\mingw64" C:\mingw64 -Force; `
32-
Remove-Item $mingwPath.FullName -Recurse -Force; `
33-
} else { `
34-
Write-Host "Renaming $($mingwPath.Name) to mingw64"; `
35-
Rename-Item $mingwPath.FullName C:\mingw64 -Force; `
36-
} `
37-
} elseif ($mingwPath) { `
38-
Write-Host "MinGW already at C:\mingw64"; `
39-
} else { `
40-
Write-Host "ERROR: Could not find MinGW directory"; `
41-
Get-ChildItem C:\ | Select-Object Name; `
42-
exit 1; `
43-
}
44-
45-
# Verify gcc installation exists
46-
RUN if (-not (Test-Path C:\mingw64\bin\gcc.exe)) { `
47-
Write-Host "ERROR: gcc.exe not found at C:\mingw64\bin\gcc.exe"; `
48-
Write-Host "Contents of C:\:"; `
49-
Get-ChildItem C:\ | Select-Object Name; `
50-
exit 1; `
51-
} else { `
52-
Write-Host "Successfully found gcc at C:\mingw64\bin\gcc.exe"; `
53-
}
54-
55-
# Verify gcc installation with full path
56-
RUN C:\mingw64\bin\gcc.exe --version
57-
58-
# Set environment variables for CGO
59-
ENV CGO_ENABLED=1
60-
ENV GOOS=windows
61-
ENV GOARCH=amd64
62-
ENV CC=C:\\mingw64\\bin\\gcc.exe
63-
ENV CXX=C:\\mingw64\\bin\\g++.exe
64-
# Add MinGW to PATH
65-
RUN [Environment]::SetEnvironmentVariable('Path', $env:Path + ';C:\mingw64\bin', [EnvironmentVariableTarget]::Machine)
66-
6734
COPY go.mod .
6835
COPY go.sum .
6936
# Download dependencies
7037
RUN go mod download
7138

39+
# 安装 7-Zip
40+
RUN Invoke-WebRequest -Uri https://www.7-zip.org/a/7z2501-x64.msi -OutFile C:/7zip.msi
41+
RUN Start-Process msiexec.exe -ArgumentList '/i C:\\7zip.msi /quiet /norestart' -Wait
42+
RUN Remove-Item C:/7zip.msi -Force
43+
44+
# # Install MinGW-w64 for CGO support (which can not run in nanoserver)
45+
# RUN Invoke-WebRequest -Uri https://github.com/niXman/mingw-builds-binaries/releases/download/15.2.0-rt_v13-rev0/x86_64-15.2.0-release-mcf-seh-ucrt-rt_v13-rev0.7z -OutFile C:/mingw.7z; & 'C:\\Program Files\\7-Zip\\7z.exe' x C:/mingw.7z -oC:/ -y; Remove-Item C:/mingw.7z -Force
46+
47+
# Use llvm-mingw-MSVCRT version instead of UCRT
48+
RUN Invoke-WebRequest -Uri https://github.com/mstorsjo/llvm-mingw/releases/download/20251021/llvm-mingw-20251021-msvcrt-x86_64.zip -OutFile C:/mingw.zip; & 'C:\\Program Files\\7-Zip\\7z.exe' x C:/mingw.zip -oC:/ -y; Remove-Item C:/mingw.zip -Force;
49+
RUN [Environment]::SetEnvironmentVariable('Path', $env:Path + ';C:\\llvm-mingw-20251021-msvcrt-x86_64\\bin', [EnvironmentVariableTarget]::Machine)
50+
51+
# # Use MSVCRT version instead of UCRT
52+
# RUN Invoke-WebRequest -Uri https://github.com/brechtsanders/winlibs_mingw/releases/download/15.2.0posix-13.0.0-msvcrt-r2/winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64msvcrt-13.0.0-r2.7z -OutFile C:/mingw.zip; & 'C:\\Program Files\\7-Zip\\7z.exe' x C:/mingw.zip -oC:/ -y; Remove-Item C:/mingw.zip -Force
53+
# # Add MinGW to PATH #ref https://stackoverflow.com/questions/42092932/appending-to-path-in-a-windows-docker-container
54+
# RUN [Environment]::SetEnvironmentVariable('Path', $env:Path + ';C:\\mingw64\\bin', [EnvironmentVariableTarget]::Machine)
55+
56+
57+
# Set environment variables for CGO
58+
ENV CGO_ENABLED=1
59+
# Verify gcc installation with full path
60+
RUN gcc --version
61+
7262
# Copy source code
7363
COPY . .
74-
64+
# Remove public\dist
65+
RUN Remove-Item public/dist -Recurse -Force
66+
# Copy built frontend assets
67+
COPY --from=frontend C:/app/frontend/OpenList-Frontend/dist ./public/dist
7568
# Build the application with CGO enabled
76-
RUN go build -o openlist.exe -trimpath -ldflags "-s -w -extldflags '-static'" .
69+
RUN go build -trimpath -ldflags='-s -w -extldflags \"-static\"' -o openlist.exe .
70+
71+
# # Compress using upx (optional)
72+
# RUN Invoke-WebRequest -Uri https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-win64.zip -OutFile C:/upx.zip; & 'C:\\Program Files\\7-Zip\\7z.exe' x C:/upx.zip -oC:/upx -y; Remove-Item C:/upx.zip -Force; C:/upx/upx-5.0.2-win64/upx.exe --best C:/app/openlist.exe
73+
7774
# Runtime stage using Windows Server Nano
78-
FROM mcr.microsoft.com/windows/nanoserver:ltsc2025
75+
# ADD https://aka.ms/vs/17/release/vc_redist.x64.exe C:/vc_redist.x64.exe
76+
# RUN C:\vc_redist.x64.exe /install /quiet /norestart
77+
# RUN Remove-Item C:/vc_redist.x64.exe -Force
78+
# RUN New-Item -ItemType Directory -Force -Path C:/vcruntime | Out-Null; \
79+
# Copy-Item -Path 'C:/Windows/System32/ucrtbase.dll' -Destination 'C:/vcruntime' -Force; \
80+
# Copy-Item -Path 'C:/Windows/System32/msvcp140.dll' -Destination 'C:/vcruntime' -Force -ErrorAction SilentlyContinue; \
81+
# Copy-Item -Path 'C:/Windows/System32/vcruntime140*.dll' -Destination 'C:/vcruntime' -Force -ErrorAction SilentlyContinue; \
82+
# Copy-Item -Path 'C:/Windows/System32/api-ms-win-crt-*.dll' -Destination 'C:/vcruntime' -Force -ErrorAction SilentlyContinue
83+
84+
# RUN Get-ChildItem -Path C:/vcruntime
85+
86+
# Directory: C:\vcruntime
87+
# Mode LastWriteTime Length Name
88+
# ---- ------------- ------ ----
89+
# -a---- 6/11/2025 5:21 AM 557728 msvcp140.dll
90+
# -a---- 10/22/2025 3:25 PM 1373304 ucrtbase.dll
91+
# -a---- 6/11/2025 5:21 AM 124544 vcruntime140.dll
92+
# -a---- 6/11/2025 5:21 AM 49792 vcruntime140_1.dll
93+
# -a---- 4/1/2024 2:59 PM 37800 vcruntime140_1_clr0400.dll
94+
# -a---- 4/1/2024 2:59 PM 98728 vcruntime140_clr0400.dll
95+
# -a---- 6/11/2025 5:21 AM 38528 vcruntime140_threads.dll
96+
97+
# FROM mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION}
98+
FROM mcr.microsoft.com/windows/nanoserver:${WINDOWS_VERSION}
7999

80100
WORKDIR C:/openlist
81101

82102
# Copy the compiled binary from builder
83103
COPY --from=builder C:/app/openlist.exe .
84-
85-
# Create data directory in PowerShell during build
86-
SHELL ["powershell", "-Command"]
87-
RUN New-Item -ItemType Directory -Path C:\\openlist\\data -Force
88-
104+
# COPY --from=builder C:/vcruntime C:/vcruntime
105+
# ENV PATH "C:\Windows\system32;C:\Program Files\PowerShell;C:\vcruntime"
89106
# Expose ports
90107
EXPOSE 5244 5245
91108

92109
# Set volume
93-
VOLUME C:\\openlist\\data
110+
VOLUME C:/openlist/data
94111

95112
# Run the application
96-
ENTRYPOINT ["C:\\openlist\\openlist.exe"]
97-
CMD ["server"]
113+
ENTRYPOINT ["C:/openlist/openlist.exe"]
114+
CMD ["server"]

0 commit comments

Comments
 (0)