Skip to content

Commit

Permalink
chore: Improve docker build caching
Browse files Browse the repository at this point in the history
  • Loading branch information
turtton committed Jun 4, 2023
1 parent 5d969f1 commit e4b3b99
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile

# Install dependencies only when needed
FROM node:20-alpine AS deps
FROM node:20-alpine AS ndeps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
Expand All @@ -11,16 +11,24 @@ WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
RUN yarn global add pnpm && pnpm i

FROM gradle:8.1.1-jdk11 AS kdeps
WORKDIR /app
COPY kotlin/gradle/wrapper/gradle-wrapper.properties kotlin/build.gradle.kts kotlin/gradle.properties kotlin/settings.gradle.kts kotlin/gradlew kotlin/gradlew.bat kotlin/kotlin-js-store ./kotlin/
WORKDIR /app/kotlin
RUN gradle wrap && chmod +x gradlew && ./gradlew assemble


# Rebuild the source code only when needed
FROM node:20-bullseye-slim AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Install java11
RUN apt -q update && apt -y -q install --no-install-recommends openjdk-11-jdk-headless

COPY --from=ndeps /app/node_modules ./node_modules
COPY --from=kdeps /app/kotlin/build /app/kotlin/.gradle ./kotlin/
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
Expand Down

0 comments on commit e4b3b99

Please sign in to comment.