mirror of
https://github.com/techgarage-ir/MTWireGuard.git
synced 2025-08-29 22:29:24 +02:00
Merge branch 'Workflow' into master
This commit is contained in:
commit
7d4a6e1864
2 changed files with 45 additions and 53 deletions
47
.github/workflows/Release.yml
vendored
47
.github/workflows/Release.yml
vendored
|
@ -41,17 +41,50 @@ jobs:
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GHCR_PAT }}
|
password: ${{ secrets.GHCR_PAT }}
|
||||||
|
|
||||||
|
- name: Install .NET SDK
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: '8.0.x'
|
||||||
|
|
||||||
|
- name: Set Runtime Identifier
|
||||||
|
id: set_rid
|
||||||
|
run: |
|
||||||
|
if [[ "$RUNNER_ARCH" == "X64" ]]; then
|
||||||
|
echo "RID=linux-x64" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "RID=linux-arm64" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Restore Dependencies
|
||||||
|
run: dotnet restore --runtime ${{ env.RID }}
|
||||||
|
|
||||||
|
- name: Build and Publish
|
||||||
|
run: dotnet publish ./UI/MTWireGuard.csproj -c Release -o publish --runtime ${{ env.RID }} --no-restore --self-contained true /p:WarningLevel=0 /p:PublishTrimmed=true
|
||||||
|
|
||||||
|
- name: Define Tags
|
||||||
|
id: define-tags
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" == "push" ]; then
|
||||||
|
echo "tags=techgarageir/mtwireguard:${{ github.ref_name }}, techgarageir/mtwireguard:latest, ghcr.io/${{ github.repository_owner }}/mtwireguard:${{ github.ref_name }}, ghcr.io/${{ github.repository_owner }}/mtwireguard:latest" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "tags=techgarageir/mtwireguard:${{ github.event.inputs.tag }}, ghcr.io/${{ github.repository_owner }}/mtwireguard:${{ github.event.inputs.tag }}" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build and push Docker images
|
- name: Build and push Docker images
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
env:
|
env:
|
||||||
IMAGE_NAME: "techgarageir/mtwireguard"
|
IMAGE_NAME: "techgarageir/mtwireguard"
|
||||||
GHCR_IMAGE_NAME: "ghcr.io/${{ github.repository_owner }}/mtwireguard"
|
GHCR_IMAGE_NAME: "ghcr.io/${{ github.repository_owner }}/mtwireguard"
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: >
|
tags: ${{ env.tags }}
|
||||||
${{
|
|
||||||
github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
- name: Debug Output
|
||||||
? format('{0}:{1}, {0}:latest, {2}:{1}, {2}:latest', env.IMAGE_NAME, github.ref_name, env.GHCR_IMAGE_NAME)
|
run: |
|
||||||
: format('{0}:{1}, {2}:{1}', env.IMAGE_NAME, github.event.inputs.tag, env.GHCR_IMAGE_NAME)
|
echo "Event Name: ${{ github.event_name }}"
|
||||||
}}
|
echo "Ref Name: ${{ github.ref_name }}"
|
||||||
|
echo "Tag Input: ${{ github.event.inputs.tag }}"
|
||||||
|
echo "Defined Tags: ${{ env.tags }}"
|
47
Dockerfile
47
Dockerfile
|
@ -1,51 +1,10 @@
|
||||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
# Define platform
|
|
||||||
ARG TARGETPLATFORM
|
|
||||||
ARG RID
|
|
||||||
|
|
||||||
# Set the RID based on the TARGETPLATFORM
|
|
||||||
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
|
|
||||||
echo "Setting RID for linux/amd64" ; RID=linux-x64 ; \
|
|
||||||
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
|
||||||
echo "Setting RID for linux/arm64" ; RID=linux-arm64 ; \
|
|
||||||
else \
|
|
||||||
echo "Unsupported platform $TARGETPLATFORM" ; exit 1 ; \
|
|
||||||
fi && \
|
|
||||||
echo "Using RID: $RID"
|
|
||||||
|
|
||||||
# Copy project files
|
|
||||||
COPY *.sln .
|
|
||||||
COPY UI/*.csproj ./UI/
|
|
||||||
COPY Application/*.csproj ./Application/
|
|
||||||
COPY MikrotikAPI/*.csproj ./MikrotikAPI/
|
|
||||||
COPY Serilog.Ui.SqliteProvider/*.csproj ./Serilog.Ui.SqliteProvider/
|
|
||||||
|
|
||||||
# Restore packages
|
|
||||||
RUN dotnet restore --runtime "$RID"
|
|
||||||
|
|
||||||
# Copy other files
|
|
||||||
COPY UI/. ./UI/
|
|
||||||
COPY Application/. ./Application/
|
|
||||||
COPY MikrotikAPI/. ./MikrotikAPI/
|
|
||||||
COPY Serilog.Ui.SqliteProvider/. ./Serilog.Ui.SqliteProvider/
|
|
||||||
|
|
||||||
# Publish project
|
|
||||||
RUN dotnet publish "./UI/MTWireGuard.csproj" -c Release \
|
|
||||||
-o /app/publish \
|
|
||||||
--no-restore \
|
|
||||||
--runtime "$RID" \
|
|
||||||
--self-contained true \
|
|
||||||
/p:WarningLevel=0 \
|
|
||||||
/p:PublishTrimmed=true
|
|
||||||
|
|
||||||
# Create final image and run project
|
|
||||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled-extra AS final
|
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled-extra AS final
|
||||||
|
|
||||||
ENV TZ=Asia/Tehran
|
ENV TZ=Asia/Tehran
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
|
# Copy the published output from the build stage (set by the GitHub Actions workflow)
|
||||||
|
COPY publish/ .
|
||||||
|
|
||||||
ENTRYPOINT ["./MTWireGuard"]
|
ENTRYPOINT ["./MTWireGuard"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue