Skip to content

Commit 70f0f5b

Browse files
committed
Update docker file & github actions with custom nuget source
1 parent bf3cda6 commit 70f0f5b

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

.github/workflows/build_docker_image.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232

3333
- name: Build and Push Docker Image
3434
run: |
35-
docker build -t ghcr.io/bardin08/trumpee-gateway:${{ github.event.release.tag_name}} .
35+
docker build -t ghcr.io/bardin08/trumpee-gateway:${{ github.event.release.tag_name}} --build-arg NUGET_API_KEY=${{ secrets.SECRET_TOKEN }} .
3636
docker tag ghcr.io/bardin08/trumpee-gateway:${{ github.event.release.tag_name}} ghcr.io/bardin08/trumpee-gateway:latest
3737
docker push ghcr.io/bardin08/trumpee-gateway --all-tags

Dockerfile

+31-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
2-
WORKDIR src
1+
ARG NUGET_API_KEY
32

4-
COPY . .
5-
RUN dotnet restore
6-
RUN dotnet publish -c Release -o out
3+
# STAGE 1: Build Environment
4+
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
5+
WORKDIR /src
76

8-
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
9-
COPY --from=build-env /src/out .
10-
ENTRYPOINT ["dotnet", "./Api.dll"]
7+
# Copy the project files first for better layer caching (if only code changes)
8+
COPY *.sln ./
9+
COPY Gateway.* ./Gateway/
10+
COPY Api.* ./Api/
11+
12+
# Add the custom NuGet source
13+
RUN dotnet nuget add source https://nuget.pkg.github.com/trumpee/index.json --name github --username trumpee --password $NUGET_API_KEY --store-password-in-clear-text
14+
15+
# Restore NuGet packages from both sources
16+
RUN dotnet restore Gateway.sln --source "https://api.nuget.org/v3/index.json" --source "https://nuget.pkg.github.com/trumpee/index.json"
17+
18+
# Build the solution
19+
RUN dotnet build Gateway.sln -c Release
20+
21+
# Publish the Api project only (assuming this is the main entry point)
22+
RUN dotnet publish ./Api/Api.csproj -c Release -o /app
23+
24+
# STAGE 2: Runtime Environment
25+
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
26+
WORKDIR /app
27+
COPY --from=build-env /app .
28+
29+
# Expose the port your application listens on (replace 80 if needed)
30+
EXPOSE 80
31+
32+
# Define the entry point for your application
33+
ENTRYPOINT ["dotnet", "Api.dll"]

0 commit comments

Comments
 (0)