Skip to content

Commit

Permalink
🐳 User can compile it with docker now
Browse files Browse the repository at this point in the history
  • Loading branch information
SydneyOwl committed Nov 12, 2024
1 parent 4fbfdc8 commit 4489985
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0
WORKDIR /source
ENV TZ=Asia/Shanghai
ARG DEBIAN_FRONTEND=noninteractive
COPY . .
RUN ls && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && \
apt update -y && \
apt install --yes --no-install-recommends \
wget \
gcc && \
rm -rf /var/lib/apt/lists/* && \
wget -O ./amsat-all-frequencies.json https://cdn.jsdelivr.net/gh/palewire/amateur-satellite-database/data/amsat-all-frequencies.json && \
sed -i 's/@COMMIT_HASH@/DockerVersion/g' Properties/VERSION.cs && \
sed -i 's/@TAG_NAME@/DockerVersion/g' Properties/VERSION.cs && \
sed -i "s/@BUILD_TIME@/$(date)/g" Properties/VERSION.cs && \
chmod +x entrypoint.sh && mv entrypoint.sh /
USER $APP_UID
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 2 additions & 0 deletions SenhaixFreqWriter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<ApplicationIcon>Asset\shx8800-icons\icon.ico</ApplicationIcon>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<!-- For Macos -->
Expand Down
45 changes: 45 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
echo "Start building..."
cd /source
mkdir builddist
ARCH="--linux-x64"

if [ ! -z "$1" ]; then
ARCH="$1"
fi

if [[ "$ARCH" != "--linux-x64" && "$ARCH" != "--osx-x64" && "$ARCH" != "--win-x64" ]]; then
echo "Invalid arg '$ARCH'; Only --linux-x64/--osx-x64/--win-x64 is allowed."
exit 1
fi

case "$ARCH" in
--linux-x64)
echo "Building for linux x64..."
dotnet restore -r linux-x64
dotnet publish -c Release -r linux-x64 /p:PublishSingleFile=true --self-contained true
mv /source/bin/Release/net6.0/linux-x64/publish/* builddist
mv ./amsat-all-frequencies.json builddist
;;
--osx-x64)
echo "Building for macos x64..."
dotnet restore -r osx-x64
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-x64 -p:UseAppHost=true -property:Configuration=Release
mv /source/bin/Release/net6.0/osx-x64/publish/SenhaixFreqWriter.app builddist
cp Asset/shx8800-icons/icon.icns builddist/SenhaixFreqWriter.app/Contents/Resources
mv ./amsat-all-frequencies.json builddist/SenhaixFreqWriter.app/Contents/MacOS
;;
--win-x64)
echo "Building for windows x64..."
dotnet restore -r win-x64
dotnet publish -c Release -r win-x64 /p:PublishSingleFile=true /p:TargetOS=Windows --self-contained true
mv /source/bin/Release/net6.0-windows10.0.19041.0/win-x64/publish/* builddist
mv ./amsat-all-frequencies.json builddist
;;
*)
echo "Invalid Args"
exit 1
;;
esac

echo "Done!"
19 changes: 19 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@

![](./readme_image/artifact.png)

### Docker

首先clone仓库并编译镜像:
```shell
git clone https://github.com/SydneyOwl/senhaix-freq-writer-enhanced
cd senhaix-freq-writer-enhanced
docker build -t "freq-writer-builder" .
```
之后需要编译软件时,运行以下命令:
```shell
docker run --rm -it -v ./dister:/source/builddist freq-writer-builder [arg]
```
其中`[arg]`可以是 `--win-x64`/`--osx-x64`/`linux-x64`,分别编译windows/macOS/Linux版本的写频软件。如未指定,默认编译Linux版本。

注意:使用该方法编译的产物仅有软件本体,不含蓝牙插件!


### 手动编译

如您使用`Rider`,按照`SenhaixFreqWriter.csproj`中的注释选择合适的框架,直接publish即可!

如您使用命令行编译,按照`SenhaixFreqWriter.csproj`中的注释选择合适的框架后,可以参考`.github/workflows/build.yml`进行编译。
Expand Down

0 comments on commit 4489985

Please sign in to comment.