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

Publish docker image #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
56 changes: 54 additions & 2 deletions .github/workflows/newbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
runs-on: ubuntu-latest
name: Versioning

outputs:
version: ${{ steps.version.outputs.version }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -85,8 +88,23 @@ jobs:
name: dotnet-test-results
path: TestResults

# validate if the code has any vulnerability
- name: Publish
run: dotnet publish ./src/AspirePoc.UI.Api/AspirePoc.UI.Api.csproj --no-restore --no-build --configuration Release --output ./publish

- name: Tag published version
uses: restackio/[email protected]
with:
file: ./publish/appsettings.json
fields: "{\"MY_APP_VERSION\": \"${{ needs.versioning.outputs.version }}\"}"

- name: Upload dotnet artifacts
uses: actions/upload-artifact@v4
with:
name: api
path: ./publish

dependency-check:
# validate if the code has any vulnerability
name: Dependency Check
needs: versioning
runs-on: ubuntu-latest
Expand Down Expand Up @@ -121,6 +139,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

# needed add the setup of .NET because the version is not long term
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
Expand All @@ -145,5 +164,38 @@ jobs:
with:
category: "/language:${{ matrix.language }}"


build-docker-image:
name: Packing and Publish
needs: [versioning, build-and-tests]
runs-on: ubuntu-latest

env:
version: ${{ needs.versioning.outputs.version }}

steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
path: app
merge-multiple: false

- name: Build Docker image
run: |
docker build -t aspire-poc:${{ vars.DOCKERHUB_REPOSITORY }}:${{ env.version }} .

# - name: Tag Docker image as Latest
# run: |
# docker tag ${{ vars.DOCKERHUB_REPOSITORY }}:${{ env.version }} ${{ vars.DOCKERHUB_REPOSITORY }}:latest
# if: github.ref == 'refs/heads/master'

# - name: Docker Login
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

# - name: Docker Push
# run: |
# docker push --all-tags thiagolunardi/todo-app

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS Base

COPY ./app/api ./app
COPY ./app/web ./app/wwwroot

WORKDIR /app
EXPOSE 8080

ENV ASPNETCORE_URLS=http://+:8080
ENTRYPOINT ["dotnet", "AspirePoc.UI.Api.dll"]
Loading