mirror of
https://github.com/freedbygrace/ActiveDirectoryToRestApi.git
synced 2026-07-26 11:28:20 +00:00
Add GH action / Dockerfile adjust
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
strategy:
|
||||
matrix:
|
||||
kind: ['linux', 'linux-arm', 'linux-arm64', 'windows', 'macOS']
|
||||
include:
|
||||
- kind: linux
|
||||
os: ubuntu-latest
|
||||
target: linux-x64
|
||||
- kind: linux-arm
|
||||
os: ubuntu-latest
|
||||
target: linux-arm
|
||||
- kind: linux-arm64
|
||||
os: ubuntu-latest
|
||||
target: linux-arm64
|
||||
- kind: windows
|
||||
os: windows-latest
|
||||
target: win-x64
|
||||
- kind: macOS
|
||||
os: macos-latest
|
||||
target: osx-x64
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
tag=$(git describe --tags --abbrev=0)
|
||||
release_name="ActiveDirectoryToRestApi-$tag-${{ matrix.target }}"
|
||||
|
||||
dotnet publish src/ActiveDirectoryToRestApi/ActiveDirectoryToRestApi.csproj --framework net8.0 --runtime "${{ matrix.target }}" --no-self-contained -p:PublishSingleFile=true -c Release -o "$release_name"
|
||||
|
||||
if [ "${{ matrix.target }}" == "win-x64" ]; then
|
||||
7z a -tzip "${release_name}.zip" "./${release_name}/*"
|
||||
else
|
||||
tar czvf "${release_name}.tar.gz" "$release_name"
|
||||
fi
|
||||
|
||||
rm -r "$release_name"
|
||||
|
||||
- name: Publish
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: "ActiveDirectoryToRestApi-*"
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
build:
|
||||
name: Build image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
zimbres/activedirectory-to-restapi
|
||||
flavor: |
|
||||
latest=true
|
||||
tags: |
|
||||
type=ref,event=tag
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
registry: docker.io
|
||||
|
||||
- name: Build and Push Image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: src/ActiveDirectoryToRestApi/Dockerfile
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
||||
@@ -7,6 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ActiveDirectoryToRestApi",
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{69C1A7CC-CE13-44EC-924A-104C576C2D34}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
|
||||
LICENSE = LICENSE
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||
RUN apt update && apt install -y --no-install-recommends libldap-2.4-2 && rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["src/ActiveDirectoryToRestApi/ActiveDirectoryToRestApi.csproj", "src/ActiveDirectoryToRestApi/"]
|
||||
RUN dotnet restore "src/ActiveDirectoryToRestApi/ActiveDirectoryToRestApi.csproj"
|
||||
RUN dotnet restore "./src/ActiveDirectoryToRestApi/./ActiveDirectoryToRestApi.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/src/ActiveDirectoryToRestApi"
|
||||
RUN dotnet build "ActiveDirectoryToRestApi.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "ActiveDirectoryToRestApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
FROM base AS final
|
||||
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
|
||||
RID=linux-x64 ; \
|
||||
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
||||
RID=linux-arm64 ; \
|
||||
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
|
||||
RID=linux-arm ; \
|
||||
fi \
|
||||
&& dotnet publish "src/ActiveDirectoryToRestApi/ActiveDirectoryToRestApi.csproj" -c Release -o /app/publish -r $RID --self-contained false
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
|
||||
RUN apt update
|
||||
RUN apt install -y libldap-2.5-0
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "ActiveDirectoryToRestApi.dll"]
|
||||
COPY --from=build /app/publish .
|
||||
|
||||
ENTRYPOINT ["./ActiveDirectoryToRestApi"]
|
||||
Reference in New Issue
Block a user