Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker ci build #765

Merged
merged 3 commits into from Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
@@ -1,6 +1,5 @@
.github/
.idea/
contrib/ci/
contrib/docker/
contrib/elasticsearch/
contrib/helm/
Expand Down
65 changes: 48 additions & 17 deletions .github/workflows/maven-ci.yml
Expand Up @@ -9,39 +9,49 @@ on: # yamllint disable-line rule:truthy

jobs:
build:
name: Standard build on Java ${{ matrix.java-version }} with compiler target ${{ matrix.java-compiler }}
name: RHEL8 ${{ matrix.build-type }} build on Java ${{ matrix.java-version }} with compiler target ${{ matrix.java-compiler }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java-compiler: ['11', '17']
java-version: ['17']
experimental: [false]
build-type: ["experimental"]
verify-build: [false]
include:
- java-compiler: '11'
java-version: '11'
experimental: false
build-type: "standard"
verify-build: true
continue-on-error: ${{ matrix.experimental }}

steps:
- name: Checkout repo
- name: Checkout
uses: actions/checkout@v4

- name: Configure Java & Maven
uses: actions/setup-java@v4
with:
java-version: '${{ matrix.java-version }}'
cache: "maven"
distribution: "corretto"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Build with Maven
run: mvn -B -e -ntp "-Dstyle.color=always" -Dmaven.compiler.release=${{ matrix.java-compiler }} verify
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Verify Changed Files
run: contrib/ci/detect-changes.sh
- name: Build
uses: docker/build-push-action@v5
with:
context: .
push: false
file: contrib/docker/Dockerfile.ci
build-args: |
java_version=${{ matrix.java-version }}
java_compiler=${{ matrix.java-compiler }}
verify_build=${{ matrix.verify-build }}
cache-from: type=gha
cache-to: type=gha,mode=max

ubi8-build:
name: UBI8 standard build with Docker on Java 11 with compiler target 11
centos7-build:
name: Centos7 legacy build on Java 11 with compiler target 11
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -58,12 +68,33 @@ jobs:
with:
context: .
push: false
file: contrib/docker/Dockerfile.ubi8
file: contrib/docker/Dockerfile.ci
build-args: |
target_os=centos7
verify_build=true
cache-from: type=gha
cache-to: type=gha,mode=max

macos-build:
name: MacOS non-standard build on Java 11 with compiler target 11
runs-on: macos-14
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Configure Java
uses: actions/setup-java@v4
with:
java-version: '11'
cache: 'maven'
distribution: 'corretto'
overwrite-settings: false

- name: Build with Maven
run: mvn -B -e -ntp "-Dstyle.color=always" clean verify -Pdist

site-build:
name: Standard maven site build
name: Maven site build
runs-on: ubuntu-latest

steps:
Expand All @@ -81,7 +112,7 @@ jobs:
run: mvn -B -e -ntp "-Dstyle.color=always" site

error-prone-build:
name: Maven build using errorProne profile
name: Maven errorProne build
runs-on: ubuntu-latest

steps:
Expand Down
127 changes: 127 additions & 0 deletions contrib/docker/Dockerfile.ci
@@ -0,0 +1,127 @@
ARG target_os=ubi8



FROM redhat/ubi8:8.9 AS base_ubi8

ENV JAVA_TOOL_OPTIONS -Dfile.encoding=UTF8
ENV PROJECT_BASE=/opt/emissary

ARG java_version=11
ARG user=emissary
ARG group=emissary
ARG uid=1000
ARG gid=1000
RUN dnf update -y \
&& dnf upgrade -y \
&& rpm --import https://yum.corretto.aws/corretto.key \
&& curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo \
&& dnf install -y java-${java_version}-amazon-corretto-devel \
&& dnf install -y glibc-langpack-en lsof \
&& groupadd -g ${gid} ${group} \
&& useradd -u ${uid} -g ${group} -m -s /bin/sh ${user} \
&& dnf clean all -y \
&& rm -rf /var/cache/yum



FROM centos:7 AS base_centos7

ENV JAVA_TOOL_OPTIONS -Dfile.encoding=UTF8
ENV PROJECT_BASE=/opt/emissary

ARG java_version=11
ARG user=emissary
ARG group=emissary
ARG uid=1000
ARG gid=1000
RUN yum update -y \
&& yum upgrade -y \
&& rpm --import https://yum.corretto.aws/corretto.key \
&& curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo \
&& yum install -y java-${java_version}-amazon-corretto-devel \
&& yum install -y which lsof \
&& groupadd -g ${gid} ${group} \
&& useradd -u ${uid} -g ${group} -m -s /bin/bash ${user} \
&& yum clean all -y \
&& rm -rf /var/cache/yum



FROM alpine:3 AS base_alpine3

ENV JAVA_TOOL_OPTIONS -Dfile.encoding=UTF8
ENV PROJECT_BASE=/opt/emissary

ARG java_version=11
ARG user=emissary
ARG group=emissary
ARG uid=1000
ARG gid=1000
RUN apk update \
&& apk upgrade \
&& apk add ca-certificates \
&& update-ca-certificates \
&& apk add --update coreutils && rm -rf /var/cache/apk/* \
&& apk add --update openjdk${java_version} tzdata curl unzip bash which lsof \
&& apk add --no-cache nss \
&& addgroup --gid ${gid} ${group} \
&& adduser --disabled-password --uid ${uid} --ingroup ${group} ${user} \
&& rm -rf /var/cache/apk/*



FROM base_${target_os} AS build

ENV MAVEN_OPTS -Xms512M -Xmx1024M -Xss1M -Djava.awt.headless=true
ENV MAVEN_HOME /opt/maven

ARG maven_version=3.9.6
RUN curl -L -o /tmp/maven.tar.gz https://dlcdn.apache.org/maven/maven-3/${maven_version}/binaries/apache-maven-${maven_version}-bin.tar.gz \
&& tar xvf /tmp/maven.tar.gz -C /opt \
&& ln -s /opt/apache-maven-${maven_version} ${MAVEN_HOME} \
&& ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn

COPY . ${PROJECT_BASE}
RUN chown -R ${user}:${group} ${PROJECT_BASE} \
&& chmod -R 744 ${PROJECT_BASE} \
&& (rm -f .mvn-classpath || true)

USER ${user}
WORKDIR ${PROJECT_BASE}

ARG java_compiler=11
RUN --mount=type=cache,uid=${uid},gid=${gid},target=/home/${user}/.m2 \
mvn -V -B -e -ntp "-Dstyle.color=always" -Dmaven.compiler.release=${java_compiler} clean verify -Pdist

ARG verify_build=false
RUN if ${verify_build} ; then ./contrib/ci/detect-changes.sh ; fi



FROM base_${target_os}

COPY --from=build ${PROJECT_BASE}/target/emissary-*-dist.tar.gz /tmp

RUN tar -xf /tmp/emissary-*-dist.tar.gz -C /opt/ \
&& version=`ls /opt | grep emissary- | awk '{ print $1 }'` \
&& echo "Linking /opt/${version} to ${PROJECT_BASE}" \
&& ln -s /opt/${version} ${PROJECT_BASE} \
&& mkdir -p ${PROJECT_BASE}/localoutput \
&& mkdir -p ${PROJECT_BASE}/target/data \
&& chmod -R a+rw ${PROJECT_BASE} \
&& chown -R ${user}:${group} ${PROJECT_BASE}* \
&& rm -f /tmp/*

USER ${user}

WORKDIR ${PROJECT_BASE}

VOLUME ${PROJECT_BASE}/target/data
VOLUME ${PROJECT_BASE}/localoutput

EXPOSE 8001

ENTRYPOINT ["./emissary"]

CMD ["server", "-a", "2", "-p", "8001"]
73 changes: 0 additions & 73 deletions contrib/docker/Dockerfile.ubi8

This file was deleted.

4 changes: 2 additions & 2 deletions contrib/docker/docker-compose.ubi8.yml
Expand Up @@ -3,10 +3,10 @@ version: "3"

services:
emissary-server:
image: emissary-ubi8
image: emissary
build:
context: ../../
dockerfile: contrib/docker/Dockerfile.ubi8
dockerfile: contrib/docker/Dockerfile.ci
environment:
- PROJECT_BASE=/opt/emissary
- JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000 -Dfile.encoding=UTF8
Expand Down