Skip to content

Commit

Permalink
Merge pull request #10 from FHIR/dev
Browse files Browse the repository at this point in the history
Multi-arch docker images.
  • Loading branch information
GinoCanessa authored Sep 4, 2024
2 parents 0b02044 + 6b38d77 commit 9c000ab
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 92 deletions.
112 changes: 56 additions & 56 deletions .github/workflows/ghcr-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,58 @@ env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

#jobs:
# build-and-push-image:
# runs-on: ubuntu-latest
#
# permissions:
# contents: read
# packages: write
# attestations: write
# id-token: write
#
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
#
# - name: Log in to the Container registry
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@v5
# with:
# labels: |
# org.opencontainers.image.title=fhir-candle
# org.opencontainers.image.description=A small in-memory FHIR server that can be used for testing and development - NOT for production workloads.
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# tags: |
# type=raw,value=latest,enable={{is_default_branch}}
#
# - name: Build and push Docker image
# id: push
# uses: docker/build-push-action@v6
# with:
# context: .
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
#
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true

jobs:
build-and-push-image:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}

permissions:
contents: read
Expand All @@ -23,6 +72,12 @@ jobs:
id-token: write

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -49,6 +104,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand All @@ -59,59 +115,3 @@ jobs:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

# jobs:
# build-and-push-image:
# runs-on: ubuntu-latest
# if: ${{ github.event.workflow_run.conclusion == 'success' }}

# permissions:
# contents: read
# packages: write
# attestations: write
# id-token: write

# steps:
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3

# - name: Checkout repository
# uses: actions/checkout@v4

# - name: Log in to the Container registry
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@v5
# with:
# labels: |
# org.opencontainers.image.title=fhir-candle
# org.opencontainers.image.description=A small in-memory FHIR server that can be used for testing and development - NOT for production workloads.
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# tags: |
# type=raw,value=latest,enable={{is_default_branch}}

# - name: Build and push Docker image
# id: push
# uses: docker/build-push-action@v6
# with:
# context: .
# platforms: linux/amd64,linux/arm64
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}

# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true
39 changes: 3 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETARCH
Expand All @@ -9,43 +9,10 @@ WORKDIR /app
COPY . ./

RUN dotnet restore -a $TARGETARCH src/fhir-candle/fhir-candle.csproj
#RUN dotnet build -a $TARGETARCH src/fhir-candle/fhir-candle.csproj -c Release -o out
RUN dotnet publish -a $TARGETARCH src/fhir-candle/fhir-candle.csproj -c Release -o out

#
## Build with platform-specific .Net RID
#RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch x64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch x64; \
#elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch arm64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch arm64; \
#elif [ "$TARGETPLATFORM" = "windows/x64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch x64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch x64; \
#elif [ "$TARGETPLATFORM" = "windows/arm64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch arm64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch arm64; \
#elif [ "$TARGETPLATFORM" = "darwin/x64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch x64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch x64; \
#elif [ "$TARGETPLATFORM" = "darwin/arm64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch arm64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch arm64; \
#else \
##echo "Unsupported architecture: $TARGETPLATFORM"; \
##exit 1; \
#dotnet restore src/fhir-candle/fhir-candle.csproj; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0; \
#fi;

#RUN dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0;
#RUN dotnet restore src/fhir-candle/fhir-candle.csproj
#RUN dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out

RUN dotnet publish -a $TARGETARCH src/fhir-candle/fhir-candle.csproj -c Release -o out --no-restore

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "fhir-candle.dll"]
Expand Down

0 comments on commit 9c000ab

Please sign in to comment.