Skip to content

Commit

Permalink
fix docker buildx
Browse files Browse the repository at this point in the history
  • Loading branch information
cthtrifork committed Jan 24, 2024
1 parent 58e87e2 commit 7eeb14f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 68 deletions.
17 changes: 17 additions & 0 deletions src/.dockerignore → .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,20 @@
**/.nuget
LICENSE
README.md
.vs/
.vscode/
**/bin/
**/obj/
**/.nuget/
secrets.dev.yaml
values.dev.yaml
LICENSE
README.md
docker-compose*
Dockerfile*
*.*proj.user
.classpath
.dockerignore
.env
.git
.gitignore
31 changes: 31 additions & 0 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /build

COPY src/NuGet-CI.Config ./NuGet.Config
COPY src/*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p ${file%.*}/ && mv $file ${file%.*}/; done

# This is only needed because swagger uses .NET 7
ENV DOTNET_ROLL_FORWARD=LatestMajor

ARG projectFile
RUN test -n "$projectFile"
RUN --mount=type=secret,id=GITHUB_TOKEN \
GITHUB_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
dotnet restore --packages $HOME/app/.nuget "$projectFile"

COPY ./src ./

RUN dotnet publish "$projectFile" -c Release -o /app/publish --no-restore --source $HOME/app/.nuget

FROM base AS final

WORKDIR /app
COPY --from=build /app/publish .

# 64198
USER $APP_UID
ENTRYPOINT ["dotnet", "Cheetah.WebApi.dll"]
26 changes: 0 additions & 26 deletions src/Cheetah.WebApi/.dockerignore

This file was deleted.

40 changes: 0 additions & 40 deletions src/Cheetah.WebApi/Dockerfile

This file was deleted.

7 changes: 5 additions & 2 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ services:
test: ["CMD", "curl", "-f", "http://cheetahwebapi:80/health"]
build:
context: ../
dockerfile: src/Cheetah.WebApi/Dockerfile
dockerfile: dockerfiles/Dockerfile
args:
- projectFile=Cheetah.WebApi/Cheetah.WebApi.csproj
- assemblyName=Cheetah.WebApi
secrets:
# Nuget restore outside Visual Studio
- GITHUB_ACTOR
- GITHUB_TOKEN
environment:
Expand All @@ -29,7 +33,6 @@ services:
- "KafkaProducerConfig__Topic=cheetahwebapi"
- "KafkaConsumerConfig__Topic=cheetahwebapi"
- "KafkaConsumerConfig__ConsumerName=cheetahwebapi"

networks:
- cheetah-infrastructure
ports:
Expand Down

0 comments on commit 7eeb14f

Please sign in to comment.