-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
59 lines (43 loc) · 1.45 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
52
53
54
55
56
57
58
59
# Stage 1: Install Gradle (Base)
FROM ubuntu:24.04 AS gradle-base
# Install necessary tools and Gradle
RUN apt-get update && \
apt-get install -y wget unzip && \
wget https://services.gradle.org/distributions/gradle-7.4.2-bin.zip -P /tmp && \
unzip -d /opt/gradle /tmp/gradle-7.4.2-bin.zip && \
rm /tmp/gradle-7.4.2-bin.zip
# Add Gradle to PATH
ENV PATH=/opt/gradle/gradle-7.4.2/bin:$PATH
# Stage 2: Kotlin Build
FROM openjdk:21-slim AS kotlin-build
# Copy Gradle installation from base stage
COPY --from=gradle-base /opt/gradle /opt/gradle
ENV PATH=/opt/gradle/gradle-7.4.2/bin:$PATH
# Set up Kotlin app build environment
WORKDIR /app
# Copy necessary build files and app sources
COPY gradlew /app/gradlew
COPY gradle /app/gradle
COPY . /app
# Ensure gradlew is executable and build the Kotlin app
RUN chmod +x ./gradlew && ./gradlew build
# Stage 3: Swift Build
FROM swift:6.0 AS swift-build
# Copy Gradle installation from base stage
COPY --from=gradle-base /opt/gradle /opt/gradle
ENV PATH=/opt/gradle/gradle-7.4.2/bin:$PATH
# Set up Swift app build environment
WORKDIR /app
# Copy app sources for Swift
COPY . /app
# Build the Swift app
RUN ./gradlew build
# Stage 4: Combine Artifacts
FROM ubuntu:24.04 AS final
# Copy Kotlin build artifacts
COPY --from=kotlin-build /app/build /final/kotlin
# Copy Swift build artifacts
COPY --from=swift-build /app/build /final/swift
# Set the working directory and default command
WORKDIR /final
CMD ["bash"]