Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add combined Docker image and update GH docker workflow to use it #5

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Image CI
name: Build combined Sylvre Docker image

on:
push:
Expand Down Expand Up @@ -32,6 +32,6 @@ jobs:
run: |
IMAGE_NAME=ghcr.io/shahzaib-m/sylvre
VERSION=${{ env.VERSION }}
docker build -f core-and-webapi/Sylvre.WebAPI/Dockerfile -t $IMAGE_NAME:$VERSION -t $IMAGE_NAME:latest core-and-webapi/
docker build -t $IMAGE_NAME:$VERSION -t $IMAGE_NAME:latest .
docker push $IMAGE_NAME:$VERSION
docker push $IMAGE_NAME:latest
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Build Core/WebAPI project
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS core-webapi-build
ARG BUILD_CONFIGURATION=Release
WORKDIR /core-and-webapi
COPY ["core-and-webapi/Sylvre.WebAPI/Sylvre.WebAPI.csproj", "Sylvre.WebAPI/"]
COPY ["core-and-webapi/Sylvre.Core/Sylvre.Core.csproj", "Sylvre.Core/"]
RUN dotnet restore "Sylvre.WebAPI/Sylvre.WebAPI.csproj"
COPY core-and-webapi/. .
WORKDIR "/core-and-webapi/Sylvre.WebAPI"
RUN dotnet build "Sylvre.WebAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build
RUN dotnet publish "Sylvre.WebAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# build webapp client project
FROM node:lts-alpine AS webapp-client-build
WORKDIR /webapp-client
COPY webapp-client/package*.json ./
RUN npm ci
COPY webapp-client/. .
RUN npm run build

# combine both builds, static webapp client files to be served by aspnet
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
WORKDIR /app
COPY --from=core-webapi-build /app/publish .
COPY --from=webapp-client-build /webapp-client/dist /app/wwwroot
EXPOSE 8080
ENTRYPOINT ["dotnet", "Sylvre.WebAPI.dll"]
Loading