diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2f32bfe --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index c865a84..aa8766e 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -2,9 +2,10 @@ name: Publish docker images on: push: - branches: [ "release" ] - pull_request: - branches: [ "release" ] + tags: [ "v*" ] + +env: + IMAGE_NAME: ${{ secrets.REGISTRY }}/${{ github.action_repository }}/domus-api jobs: publish: @@ -24,8 +25,12 @@ jobs: - name: Build projects run: dotnet build -c Release + - name: Get version + id: version + uses: battila7/get-version-action@v2 + - name: Build docker images - run: docker build -f file_location -t image_name . + run: docker build -f Domus.Api/Dockerfile -t ${{ IMAGE_NAME }}:${{ steps.version.outputs.version-without-v }} . - name: Publish images - run: docker push image_name + run: docker push ${{ IMAGE_NAME }}:${{ steps.version.outputs.version-without-v }} diff --git a/Domus.Api/Dockerfile b/Domus.Api/Dockerfile new file mode 100644 index 0000000..2519921 --- /dev/null +++ b/Domus.Api/Dockerfile @@ -0,0 +1,20 @@ +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY ["Domus.Api/Domus.Api.csproj", "Domus.Api/"] +RUN dotnet restore "Domus.Api/Domus.Api.csproj" +COPY . . +WORKDIR "/src/Domus.Api" +RUN dotnet build "Domus.Api.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Domus.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Domus.Api.dll"]