This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Dockerfile
51 lines (36 loc) · 1.52 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Build it
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
ARG TARGETPLATFORM
WORKDIR /Silk
# Copy the main source project files
COPY src/*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p src/${file%.*}/ && mv $file src/${file%.*}/; done
# Copy the test project files
COPY tests/*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p tests/${file%.*}/ && mv $file tests/${file%.*}/; done
# Copy the plugins, too.
COPY plugins/*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p plugins/${file%.*}/ && mv $file plugins/${file%.*}/; done
COPY ../Directory.Build.targets ./
COPY ../Silk.sln .
RUN dotnet restore -p Silk
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ] ; then DOTNET_TARGET=linux-musl-arm64 ; else DOTNET_TARGET=linux-musl-x64 ; fi \
&& echo $DOTNET_TARGET > /tmp/rid
WORKDIR /Silk
COPY . ./
RUN echo "Compling for $(cat /tmp/rid)"
RUN dotnet publish ./src/Silk/Silk.csproj --no-restore -c Release -o out -r $(cat /tmp/rid) --self-contained -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true
# Run it
FROM --platform=$TARGETARCH mcr.microsoft.com/dotnet/aspnet:7.0-alpine
# Install cultures (same approach as Alpine SDK image)
RUN apk add --no-cache icu-libs
# Disable the invariant mode (set in base image)
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
# Update OpenSSL for the bot to properly work (Discord sucks)
RUN apk upgrade --update-cache --available && \
apk add openssl && \
rm -rf /var/cache/apk/*
WORKDIR /Silk
COPY --from=build /Silk/out .
RUN chmod +x ./Silk
CMD ["./Silk"]