From 3e626024594b8a10eccf37a8a752c90ddc0a1207 Mon Sep 17 00:00:00 2001 From: Braydon Date: Fri, 10 May 2024 10:54:51 -0700 Subject: [PATCH 1/3] Add docker build for linux release. --- .docker/linux-release.Dockerfile | 22 ++++++++++++++++++++++ gradle.properties | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .docker/linux-release.Dockerfile diff --git a/.docker/linux-release.Dockerfile b/.docker/linux-release.Dockerfile new file mode 100644 index 0000000..6daabf7 --- /dev/null +++ b/.docker/linux-release.Dockerfile @@ -0,0 +1,22 @@ +# Use debian +FROM debian:bullseye-slim AS BUILD + +# Upgrade all packages and install dependencies +RUN apt-get update \ + && apt-get upgrade -y +RUN apt-get install -y bash git libsqlite3-dev libcurl4-gnutls-dev openjdk-17-jdk \ + && apt clean + +# Git pull phoenixd source at specified tag/branch and compile phoenixd +WORKDIR /phoenixd + +# Copy the repository to the container +COPY . . + +# Compile the package +RUN ./gradlew packageLinuxX64 + +# Alpine image to minimize final image size +FROM eclipse-temurin:21-jre-alpine as FINAL + +COPY --from=BUILD /phoenixd/build/distributions/phoenix-*-jvm.tar . diff --git a/gradle.properties b/gradle.properties index c069fca..4ad1c0d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,5 @@ kotlin.code.style=official kotlin.incremental.multiplatform=true kotlin.mpp.stability.nowarn=true kotlin.mpp.enableCInteropCommonization=true -kotlin.native.ignoreDisabledTargets=true \ No newline at end of file +kotlin.native.ignoreDisabledTargets=true +kotlin.native.cacheKind.linuxX64=none From 6a8572036ce7c988dad8b7011c7080646505e802 Mon Sep 17 00:00:00 2001 From: Braydon Date: Fri, 10 May 2024 12:59:41 -0700 Subject: [PATCH 2/3] Fix docker build for linux64. --- .docker/linux-release.Dockerfile | 38 +++++++++++++++++++++++--------- .gitignore | 1 + README.md | 8 +++++++ 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/.docker/linux-release.Dockerfile b/.docker/linux-release.Dockerfile index 6daabf7..89e5992 100644 --- a/.docker/linux-release.Dockerfile +++ b/.docker/linux-release.Dockerfile @@ -1,22 +1,38 @@ -# Use debian -FROM debian:bullseye-slim AS BUILD +FROM ubuntu:18.04 as build + +ARG CURL_VERSION=7.88.1 # Upgrade all packages and install dependencies RUN apt-get update \ && apt-get upgrade -y -RUN apt-get install -y bash git libsqlite3-dev libcurl4-gnutls-dev openjdk-17-jdk \ - && apt clean +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + openjdk-17-jdk \ + openssh-client \ + libgnutls28-dev \ + libsqlite3-dev \ + build-essential \ + git \ + wget \ + && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Git pull phoenixd source at specified tag/branch and compile phoenixd -WORKDIR /phoenixd +WORKDIR /curl +RUN wget https://curl.se/download/curl-${CURL_VERSION}.tar.bz2 \ + && tar -xjvf curl-${CURL_VERSION}.tar.bz2 \ + && cd curl-${CURL_VERSION} \ + && ./configure --with-gnutls=/lib/x86_64-linux-gnu/ \ + && make \ + && make install \ + && ldconfig -# Copy the repository to the container +# Copy phoenixd source +WORKDIR /phoenixd COPY . . -# Compile the package +# Build RUN ./gradlew packageLinuxX64 -# Alpine image to minimize final image size -FROM eclipse-temurin:21-jre-alpine as FINAL +# Copy the build to host machine +FROM ubuntu:18.04 as final +COPY --from=BUILD /phoenixd/build/distributions/* . -COPY --from=BUILD /phoenixd/build/distributions/phoenix-*-jvm.tar . diff --git a/.gitignore b/.gitignore index a6d3486..efdeab5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .gradle build/ +out/ .cxx # this file is local to the dev environment and must not be pushed! diff --git a/README.md b/README.md index 5349615..9f04a56 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,12 @@ Requires `libsqlite-dev` and `libcurl4-gnutls-dev`, both compiled against `glibc ### JVM ```shell ./gradlew distZip +``` + +## Build with Docker + +### Native Linux/WSL + +```shell +DOCKER_BUILDKIT=1 docker build --file .docker/linux-release.Dockerfile --output type=local,dest=./out . ``` \ No newline at end of file From 22d37eaf9026f9dcb4939e87aecf0c660d19d7c3 Mon Sep 17 00:00:00 2001 From: Braydon Date: Fri, 10 May 2024 16:50:14 -0700 Subject: [PATCH 3/3] Use docker build cache. --- .docker/linux-release.Dockerfile | 13 +++++++++++-- gradle.properties | 3 +-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.docker/linux-release.Dockerfile b/.docker/linux-release.Dockerfile index 89e5992..4f12327 100644 --- a/.docker/linux-release.Dockerfile +++ b/.docker/linux-release.Dockerfile @@ -30,9 +30,18 @@ WORKDIR /phoenixd COPY . . # Build -RUN ./gradlew packageLinuxX64 +RUN \ + --mount=type=cache,target=/phoenixd/build \ + --mount=type=cache,target=/root/.m2 \ + --mount=type=cache,target=/phoenixd/.gradle \ + --mount=type=cache,target=/root/.gradle \ + --mount=type=cache,target=/root/.konan \ + ./gradlew --build-cache packageLinuxX64 && \ + mkdir /phoenixd/build-distributions && \ + cp -R /phoenixd/build/distributions/* /phoenixd/build-distributions/ && \ + ./gradlew --stop # Copy the build to host machine FROM ubuntu:18.04 as final -COPY --from=BUILD /phoenixd/build/distributions/* . +COPY --from=BUILD /phoenixd/build-distributions/* . diff --git a/gradle.properties b/gradle.properties index 4ad1c0d..c069fca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,5 +6,4 @@ kotlin.code.style=official kotlin.incremental.multiplatform=true kotlin.mpp.stability.nowarn=true kotlin.mpp.enableCInteropCommonization=true -kotlin.native.ignoreDisabledTargets=true -kotlin.native.cacheKind.linuxX64=none +kotlin.native.ignoreDisabledTargets=true \ No newline at end of file