-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.android
More file actions
77 lines (62 loc) · 2.25 KB
/
Copy pathDockerfile.android
File metadata and controls
77 lines (62 loc) · 2.25 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Dockerfile for building .NET MAUI Android APK
# Based on .NET 11 with Android SDK
FROM mcr.microsoft.com/dotnet/sdk:11.0 AS build
# Install dependencies
RUN apt-get update && apt-get install -y \
openjdk-17-jdk \
wget \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Set Java home
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
# Install Android SDK
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV PATH="${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools"
# Download and install Android command-line tools
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/cmdline-tools.zip && \
unzip -q /tmp/cmdline-tools.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest && \
rm /tmp/cmdline-tools.zip
# Accept licenses and install required Android SDK components
RUN yes | sdkmanager --licenses && \
sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0"
# Install .NET MAUI Android workload
RUN dotnet workload install maui-android --skip-sign-check
WORKDIR /src
# Copy solution-level config
COPY Directory.Build.props ./
COPY Directory.Packages.props ./
# Copy Core project
COPY Physiquinator.Core/Physiquinator.Core.csproj ./Physiquinator.Core/
COPY Physiquinator.Core/ ./Physiquinator.Core/
# Copy app project
COPY Physiquinator.csproj .
COPY *.xaml .
COPY *.razor .
COPY *.cs .
COPY Components/ ./Components/
COPY Platforms/ ./Platforms/
COPY Properties/ ./Properties/
COPY Resources/ ./Resources/
COPY Services/ ./Services/
COPY wwwroot/ ./wwwroot/
# Restore dependencies for Android only
RUN dotnet restore Physiquinator.csproj \
-p:TargetFrameworks=net11.0-android
# Build Android APK
RUN dotnet publish Physiquinator.csproj \
-f net11.0-android \
-c Release \
-p:TargetFrameworks=net11.0-android \
-p:AndroidPackageFormat=apk \
-p:AndroidKeyStore=false \
-p:NoWarn=XA0141 \
-o /app/output
# Export the APK
FROM scratch AS export
COPY --from=build /app/output/*-Signed.apk /
# Default stage for testing
FROM build AS test
WORKDIR /app/output
RUN ls -lah && echo "Build completed successfully"