Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/maxnatamo/fetcharr into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
maxnatamo committed Jul 27, 2024
2 parents 79a9304 + 449ec99 commit 24870f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .build/Build.Docker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ partial class Build : NukeBuild

private string DockerImageTag => $"{DockerImage}:{DockerTag}";

private string[] DockerImagePlatforms => ["linux/amd64", "linux/arm", "linux/arm64"];

Target BuildImage => _ => _
.DependsOn(Test)
.DependsOn(Format)
Expand All @@ -22,6 +24,7 @@ partial class Build : NukeBuild
.SetPath(".")
.SetFile("Dockerfile")
.SetTag(this.DockerImageTag)
.SetPlatform(string.Join(",", this.DockerImagePlatforms))
.AddCacheFrom("type=gha")
.AddCacheTo("type=gha,mode=max")
.AddLabel("org.opencontainers.image.source=https://github.com/fetcharr/fetcharr")
Expand Down
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# syntax=docker/dockerfile:1.9-labs

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
WORKDIR /app
EXPOSE 5000

ARG TARGETARCH

COPY --parents ./src/*.props ./src/**/*.csproj ./
RUN dotnet restore src/API/src/Fetcharr.API.csproj
RUN dotnet restore src/API/src/Fetcharr.API.csproj -a $TARGETARCH

COPY . .
RUN dotnet publish src/API/src/Fetcharr.API.csproj --no-restore -o /app
RUN dotnet publish src/API/src/Fetcharr.API.csproj -a $TARGETARCH --no-restore -o /out

FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
WORKDIR /app
Expand All @@ -17,11 +19,11 @@ ENV FETCHARR_BASE_DIR="/app/fetcharr" \
FETCHARR_CONFIG_DIR="/config"

RUN set -ex; \
mkdir -p /config && chown 1000:1000 /config;
mkdir -p /config && chown $APP_UID /config;

COPY --from=build-env --chown=1000:1000 /app /app/fetcharr
COPY --from=build-env --chown=$APP_UID /out /app/fetcharr

USER 1000:1000
USER $APP_UID
VOLUME /config

ENTRYPOINT ["dotnet", "/app/fetcharr/Fetcharr.API.dll"]

0 comments on commit 24870f2

Please sign in to comment.