Skip to content

Commit

Permalink
fix: ARM build for .NET
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Dec 6, 2023
1 parent 419581e commit 020e458
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 18 deletions.
23 changes: 23 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ includes:
helm: Taskfile.helm.yml
tear: tasks/Taskfile.tear.yml
stop: tasks/Taskfile.stop.yml
util: tasks/Taskfile.util.yml

tasks:
migration:create:
Expand Down Expand Up @@ -36,9 +37,31 @@ tasks:
- ./scripts/local/exec.sh ./config/dev.yaml {{.CLI_ARGS}}
dev:
desc: Starts developing application
env:
DOTNET_WATCH_RESTART_ON_RUDE_EDIT: true
cmds:
- ./scripts/local/dev.sh ./config/dev.yaml dotnet watch run --project App
stop:
desc: Stops development in tilt
cmds:
- tilt down

latest:
desc: Get the latest versions of dependencies
cmds:
- task: util:latest-oci
vars:
NAME: bromine
OCI: ghcr.io/atomicloud/sulfoxide.bromine/sulfoxide-bromine
- task: util:latest-oci
vars:
NAME: postgres
OCI: registry-1.docker.io/bitnamicharts/postgresql
- task: util:latest-oci
vars:
NAME: minio
OCI: registry-1.docker.io/bitnamicharts/minio
- task: util:latest-oci
vars:
NAME: dragonfly
OCI: ghcr.io/dragonflydb/dragonfly/helm/dragonfly
7 changes: 4 additions & 3 deletions infra/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ARG TARGETARCH
WORKDIR /src
COPY ["App/App.csproj", "App/"]
RUN dotnet restore "App/App.csproj"
RUN dotnet restore -a $TARGETARCH "App/App.csproj"
COPY . .
WORKDIR "/src/App"
RUN dotnet build "App.csproj" -c Release -o /app/build
RUN dotnet build "App.csproj" -a $TARGETARCH -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "App.csproj" -c Release -o /app/publish /p:UseAppHost=false
Expand Down
9 changes: 5 additions & 4 deletions infra/migrate.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine as builder
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine as builder
ARG TARGETARCH
RUN addgroup -g 1000 dotnet && adduser -G dotnet -u 1000 dotnet -D
USER dotnet
WORKDIR /app
COPY --chown=dotnet "App/App.csproj" "App/"
RUN dotnet restore "App/App.csproj"
RUN dotnet restore -a $TARGETARCH "App/App.csproj"
COPY --chown=dotnet . .
WORKDIR /app
RUN dotnet tool install --global dotnet-ef
RUN dotnet tool install -a $TARGETARCH --global dotnet-ef
ENV PATH="$PATH:/home/dotnet/.dotnet/tools"
ENV LANDSCAPE=lapras
RUN dotnet-ef migrations bundle --project ./App
RUN dotnet-ef migrations bundle -a $TARGETARCH --project ./App
CMD [ "./efbundle" ]
10 changes: 5 additions & 5 deletions infra/root_chart/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ dependencies:
version: 1.3.0
- name: postgresql
repository: oci://registry-1.docker.io/bitnamicharts
version: 13.2.15
version: 13.2.24
- name: minio
repository: oci://registry-1.docker.io/bitnamicharts
version: 12.10.2
version: 12.10.4
- name: dragonfly
repository: oci://ghcr.io/dragonflydb/dragonfly/helm
version: v1.12.1
digest: sha256:347399b26f5544bae01d47d56e4b9069707f0dc1ba2f418455cb340db749dc6e
generated: "2023-11-25T00:09:09.251411+08:00"
version: v1.13.0
digest: sha256:57a852edacd98ee1680c663491083d2cf9e0dc8fbe1d0fe223459892a55271ea
generated: "2023-12-06T18:13:10.245697+08:00"
6 changes: 3 additions & 3 deletions infra/root_chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ dependencies:
alias: bromine
repository: oci://ghcr.io/atomicloud/sulfoxide.bromine
- name: postgresql
version: 13.2.15
version: 13.2.24
repository: oci://registry-1.docker.io/bitnamicharts
alias: maindb
condition: maindb.enable
- name: minio
repository: oci://registry-1.docker.io/bitnamicharts
version: 12.10.2
version: 12.10.4
alias: mainstorage
condition: mainstorage.enable
- name: dragonfly
repository: oci://ghcr.io/dragonflydb/dragonfly/helm
version: v1.12.1
version: v1.13.0
alias: maincache
condition: maincache.enable
6 changes: 3 additions & 3 deletions infra/root_chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Root Chart to a single Service
| file://../api_chart | api(dotnet-chart) | 0.1.0 |
| file://../migration_chart | migration(dotnet-migration) | 0.1.0 |
| oci://ghcr.io/atomicloud/sulfoxide.bromine | bromine(sulfoxide-bromine) | 1.3.0 |
| oci://ghcr.io/dragonflydb/dragonfly/helm | maincache(dragonfly) | v1.12.1 |
| oci://registry-1.docker.io/bitnamicharts | mainstorage(minio) | 12.10.2 |
| oci://registry-1.docker.io/bitnamicharts | maindb(postgresql) | 13.2.15 |
| oci://ghcr.io/dragonflydb/dragonfly/helm | maincache(dragonfly) | v1.13.0 |
| oci://registry-1.docker.io/bitnamicharts | mainstorage(minio) | 12.10.4 |
| oci://registry-1.docker.io/bitnamicharts | maindb(postgresql) | 13.2.24 |

## Values

Expand Down
23 changes: 23 additions & 0 deletions tasks/Taskfile.util.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3"

tasks:
latest-helm:
internal: true
silent: true
desc: Get the latest version of a Helm Chart
cmds:
- helm repo add {{.REPO_NAME}} {{.REPO_URL}} > /dev/null
- helm repo update > /dev/null
- >-
echo "{{.CHART_NAME}}:
$(helm search repo {{.REPO_NAME}}/{{.CHART_NAME}} --versions --max-col-width=0
| grep {{.REPO_NAME}}/{{.CHART_NAME}}
| head -n 1
| awk '{print $2}')"
latest-oci:
internal: true
silent: true
desc: Get the latest version of a Helm Chart in OCI version
cmds:
- >-
echo "{{.NAME}}: $(skopeo list-tags docker://{{.OCI}} | jq -r '.Tags[]' | sort -V | tail -n 1)"

0 comments on commit 020e458

Please sign in to comment.