Skip to content

Commit

Permalink
Feature/m1 docker build support (#376)
Browse files Browse the repository at this point in the history
* feature/m1-docker-build-support

- separate jammy and alpine
- add zilla version as env var
- add the docker platform to properties
- don't need to use alpine for build

* docker image tagging options

separate alpine base image from the default image and add more tagging options

* set the version env var in the alpine build

* remove the suffix for local build

* make version tagging more explicit for each profile

* move the alpine specific builds into the docker-image module

* reduce the folder complexity and add child pom placeholders

* revert the docker-image pom to develop

* Use buildx for multi-arch images, build alpine image for release only

* Move inline assembly to descriptor file and reference from alpine image

---------

Co-authored-by: John Fallows <john.r.fallows@gmail.com>
  • Loading branch information
vordimous and jfallows authored Oct 7, 2023
1 parent 1bd85f1 commit cc14195
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 61 deletions.
104 changes: 51 additions & 53 deletions cloud/docker-image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
<version>0.43.2</version>
<configuration>
<filter>${*}</filter>
<images>
<images combine.children="append">
<image>
<alias>zilla</alias>
<name>ghcr.io/aklivity/zilla:%v</name>
Expand All @@ -262,60 +262,15 @@
<tags>
<tag>latest</tag>
</tags>
<createImageOptions>
<platform>linux/x86_64</platform>
</createImageOptions>
<buildx>
<platforms>
<platform>linux/amd64</platform>
<platform>linux/arm64</platform>
</platforms>
</buildx>
<assemblies>
<assembly>
<inline>
<fileSets>
<fileSet>
<directory>${settings.localRepository}</directory>
<outputDirectory>./</outputDirectory>
<useDefaultExcludes>false</useDefaultExcludes>
<includes>
<include>io/aklivity/zilla/zilla/**</include>
<include>io/aklivity/zilla/runtime/**</include>
<include>io/aklivity/zilla/engine/**</include>
<include>io/aklivity/zilla/binding-*/**</include>
<include>io/aklivity/zilla/catalog-*/**</include>
<include>io/aklivity/zilla/exporter-*/**</include>
<include>io/aklivity/zilla/guard-*/**</include>
<include>io/aklivity/zilla/metrics-*/**</include>
<include>io/aklivity/zilla/validator-*/**</include>
<include>io/aklivity/zilla/vault-*/**</include>
<include>io/aklivity/zilla/command/**</include>
<include>io/aklivity/zilla/command-*/**</include>
<include>io/aklivity/zilla/manager/**</include>
<include>io/aklivity/zilla/incubator/**</include>
<include>org/agrona/**</include>
<include>org/apache/apache/**</include>
<include>org/apache/avro/**</include>
<include>org/apache/maven/maven/**</include>
<include>org/apache/maven/maven-parent/**</include>
<include>jakarta/json/**</include>
<include>jakarta/inject/**</include>
<include>org/leadpony/justify/**</include>
<include>org/leadpony/joy/**</include>
<include>org/snakeyaml/snakeyaml-engine/**</include>
<include>org/eclipse/yasson/**</include>
<include>org/glassfish/**</include>
<include>com/github/rvesse/**</include>
<include>com/guicedee/**</include>
<include>org/eclipse/ee4j/**</include>
<include>com/ibm/icu/**</include>
<include>org/bitbucket/b_c/jose4j/**</include>
<include>org/slf4j/**</include>
<include>org/antlr/**</include>
<include>org/sonatype/oss/**</include>
<include>com/fasterxml/oss-parent/**</include>
<include>com/fasterxml/jackson/**</include>
<include>org/yaml/snakeyaml/**</include>
<include>org/junit/**</include>
</includes>
</fileSet>
</fileSets>
</inline>
<descriptor>assembly.xml</descriptor>
</assembly>
</assemblies>
</build>
Expand Down Expand Up @@ -407,5 +362,48 @@
</dependency>
</dependencies>
</profile>

<profile>
<id>alpine</id>
<activation>
<property>
<name>release</name>
<value>true</value>
</property>
</activation>

<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<alias>zilla-alpine</alias>
<name>ghcr.io/aklivity/zilla:%v-alpine</name>
<build>
<dockerFile>${docker.context}/alpine.Dockerfile</dockerFile>
<tags>
<tag>alpine</tag>
</tags>
<buildx>
<platforms>
<platform>linux/amd64</platform>
</platforms>
</buildx>
<assemblies>
<assembly>
<descriptor>assembly.xml</descriptor>
</assembly>
</assemblies>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
67 changes: 67 additions & 0 deletions cloud/docker-image/src/main/docker/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!--
Copyright 2021-2023 Aklivity Inc
Licensed under the Aklivity Community License (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
https://www.aklivity.io/aklivity-community-license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
<fileSets>
<fileSet>
<directory>${settings.localRepository}</directory>
<outputDirectory>./</outputDirectory>
<useDefaultExcludes>false</useDefaultExcludes>
<includes>
<include>io/aklivity/zilla/zilla/**</include>
<include>io/aklivity/zilla/runtime/**</include>
<include>io/aklivity/zilla/engine/**</include>
<include>io/aklivity/zilla/binding-*/**</include>
<include>io/aklivity/zilla/catalog-*/**</include>
<include>io/aklivity/zilla/exporter-*/**</include>
<include>io/aklivity/zilla/guard-*/**</include>
<include>io/aklivity/zilla/metrics-*/**</include>
<include>io/aklivity/zilla/validator-*/**</include>
<include>io/aklivity/zilla/vault-*/**</include>
<include>io/aklivity/zilla/command/**</include>
<include>io/aklivity/zilla/command-*/**</include>
<include>io/aklivity/zilla/manager/**</include>
<include>io/aklivity/zilla/incubator/**</include>
<include>org/agrona/**</include>
<include>org/apache/apache/**</include>
<include>org/apache/avro/**</include>
<include>org/apache/maven/maven/**</include>
<include>org/apache/maven/maven-parent/**</include>
<include>jakarta/json/**</include>
<include>jakarta/inject/**</include>
<include>org/leadpony/justify/**</include>
<include>org/leadpony/joy/**</include>
<include>org/snakeyaml/snakeyaml-engine/**</include>
<include>org/eclipse/yasson/**</include>
<include>org/glassfish/**</include>
<include>com/github/rvesse/**</include>
<include>com/guicedee/**</include>
<include>org/eclipse/ee4j/**</include>
<include>com/ibm/icu/**</include>
<include>org/bitbucket/b_c/jose4j/**</include>
<include>org/slf4j/**</include>
<include>org/antlr/**</include>
<include>org/sonatype/oss/**</include>
<include>com/fasterxml/oss-parent/**</include>
<include>com/fasterxml/jackson/**</include>
<include>org/yaml/snakeyaml/**</include>
<include>org/junit/**</include>
</includes>
</fileSet>
</fileSets>
</assembly>
10 changes: 6 additions & 4 deletions cloud/docker-image/src/main/docker/incubator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
# specific language governing permissions and limitations under the License.
#

FROM eclipse-temurin:20-alpine AS build
FROM eclipse-temurin:20-jdk AS build

RUN apt update && apt install -y gettext

COPY maven /root/.m2/repository

COPY zpmw zpmw
COPY zpm.json.template zpm.json.template

RUN apk add --no-cache gettext
RUN cat zpm.json.template | env VERSION=${project.version} envsubst > zpm.json

RUN apk add --no-cache wget
RUN ./zpmw install --debug --exclude-remote-repositories
RUN ./zpmw clean --keep-image

FROM alpine:3.18.3
FROM ubuntu:jammy-20230916

ENV ZILLA_VERSION ${project.version}

COPY --from=build /.zpm /opt/zilla/.zpm
COPY --from=build /zilla /opt/zilla/zilla
Expand Down
10 changes: 6 additions & 4 deletions cloud/docker-image/src/main/docker/release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
# specific language governing permissions and limitations under the License.
#

FROM eclipse-temurin:20-alpine AS build
FROM eclipse-temurin:20-jdk AS build

RUN apt update && apt install -y gettext

COPY maven /root/.m2/repository

COPY zpmw zpmw
COPY zpm.json.template zpm.json.template

RUN apk add --no-cache gettext
RUN cat zpm.json.template | env VERSION=${project.version} envsubst > zpm.json

RUN apk add --no-cache wget
RUN ./zpmw install --debug --exclude-remote-repositories
RUN ./zpmw clean --keep-image

FROM alpine:3.18.3
FROM ubuntu:jammy-20230916

ENV ZILLA_VERSION ${project.version}

COPY --from=build /.zpm /opt/zilla/.zpm
COPY --from=build /zilla /opt/zilla/zilla
Expand Down
38 changes: 38 additions & 0 deletions cloud/docker-image/src/main/docker/release/alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright 2021-2023 Aklivity Inc
#
# Licensed under the Aklivity Community License (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://www.aklivity.io/aklivity-community-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

FROM eclipse-temurin:20-alpine AS build

COPY maven /root/.m2/repository

COPY ../zpmw zpmw
COPY ../zpm.json.template zpm.json.template

RUN apk add --no-cache gettext
RUN cat zpm.json.template | env VERSION=${project.version} envsubst > zpm.json

RUN apk add --no-cache wget
RUN ./zpmw install --debug --exclude-remote-repositories
RUN ./zpmw clean --keep-image

FROM alpine:3.18.3

ENV ZILLA_VERSION ${project.version}

COPY --from=build /.zpm /opt/zilla/.zpm
COPY --from=build /zilla /opt/zilla/zilla
COPY ../zilla.properties /opt/zilla/.zilla/zilla.properties

ENTRYPOINT ["/opt/zilla/zilla"]

0 comments on commit cc14195

Please sign in to comment.