Skip to content

Commit

Permalink
Fix docker
Browse files Browse the repository at this point in the history
  • Loading branch information
22388o committed Dec 11, 2024
1 parent 7e046f7 commit 609ce85
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
FROM openjdk:21-slim AS kotlin-build
# 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
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

# Explicitly copy gradlew and gradle directory (in case copy context is problematic)
# Copy necessary build files and app sources
COPY gradlew /app/gradlew
COPY gradle /app/gradle
COPY . /app

# Ensure gradlew is present and executable
RUN ls -l /app/gradlew && chmod +x /app/gradlew

# Build Kotlin app
RUN ./gradlew build
# Ensure gradlew is executable and build the Kotlin app
RUN chmod +x ./gradlew && ./gradlew build

# Stage 2: Swift Build
# Stage 3: Swift Build
FROM swift:6.0 AS swift-build

# 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

# Add Gradle to PATH
# 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 Swift app
# Build the Swift app
RUN ./gradlew build

# Final Stage: Combine Artifacts
# Stage 4: Combine Artifacts
FROM ubuntu:24.04 AS final

# Copy Kotlin build artifacts
COPY --from=kotlin-build /app /final/kotlin
COPY --from=kotlin-build /app/build /final/kotlin

# Copy Swift build artifacts
COPY --from=swift-build /app /final/swift
COPY --from=swift-build /app/build /final/swift

# Set the working directory and default command
WORKDIR /final
Expand Down

0 comments on commit 609ce85

Please sign in to comment.