Skip to content

Commit

Permalink
move to Dockerfile.centos7
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-mlb committed Apr 25, 2024
1 parent cccf731 commit 4c24a5c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-ci.yml
Expand Up @@ -63,7 +63,7 @@ jobs:
with:
context: .
push: false
file: contrib/docker/Dockerfile
file: contrib/docker/Dockerfile.centos7
cache-from: type=gha
cache-to: type=gha,mode=max

Expand Down
12 changes: 11 additions & 1 deletion DEVELOPING.md
Expand Up @@ -601,8 +601,18 @@ a non-root user.

### Build Emissary Docker Image

We can use Docker directly to build Emissary:
Maven can be used to create the docker image. There is a profile that was created to run the docker image build that, by default,
has been turned off. We'll need to add the docker profile, along with the dist profile, to trigger an assembly. From the
project root, run the following maven command:

```
mvn clean install -Pdist,docker
```

Alternatively, we can use Docker directly. First run a full maven build and then run the ```docker build``` command:

```
mvn clean install -Pdist
docker build -f contrib/docker/Dockerfile . -t emissary
```

Expand Down
75 changes: 16 additions & 59 deletions contrib/docker/Dockerfile
@@ -1,71 +1,28 @@
ARG IMG_NAME=centos
ARG IMG_TAG=7
FROM ${IMG_NAME}:${IMG_TAG} AS base
FROM centos:7

ARG java_version=11
ARG user=emissary
ARG group=emissary
ARG uid=1000
ARG gid=1000
RUN yum update -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-11-amazon-corretto-devel \
&& yum clean all -y \
&& rm -rf /var/cache/yum

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

RUN 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 \
&& groupadd -g ${gid} ${group} \
&& useradd -u ${uid} -g ${group} -m -s /bin/bash ${user} \
&& yum clean all -y \
&& rm -rf /var/cache/yum



FROM base AS build

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

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
ADD target/emissary-*-dist.tar.gz /opt

COPY . /opt/emissary
RUN chown -R ${user}:${group} /opt/emissary \
&& chmod -R 744 /opt/emissary \
&& (rm -f .mvn-classpath || true)
RUN ls -al /opt && \
version=`ls /opt | grep emissary- | awk '{ print $1 }'` && \
echo "Linking /opt/${version} to /opt/emissary" && \
ln -s /opt/${version} /opt/emissary && \
mkdir -p /opt/emissary/localoutput && \
chmod -R a+rw /opt/emissary

USER ${user}
WORKDIR /opt/emissary
RUN --mount=type=cache,uid=${uid},gid=${gid},target=/home/${user}/.m2 \
mvn -V -B -e -ntp "-Dstyle.color=always" clean verify -Pdist


FROM base

COPY --from=build /opt/emissary/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 /opt/emissary" \
&& ln -s /opt/${version} /opt/emissary \
&& mkdir -p /opt/emissary/localoutput \
&& mkdir -p /opt/emissary/target/data \
&& chmod -R a+rw /opt/emissary \
&& chown -R ${user}:${group} /opt/emissary* \
&& rm -f /tmp/*

USER ${user}
ENV PROJECT_BASE=/opt/emissary

WORKDIR /opt/emissary

VOLUME /opt/emissary/target/data
VOLUME /opt/emissary/localoutput

EXPOSE 8001
EXPOSE 8000 8001

ENTRYPOINT ["./emissary"]

Expand Down
72 changes: 72 additions & 0 deletions contrib/docker/Dockerfile.centos7
@@ -0,0 +1,72 @@
ARG IMG_NAME=centos
ARG IMG_TAG=7
FROM ${IMG_NAME}:${IMG_TAG} AS base

ARG java_version=11
ARG user=emissary
ARG group=emissary
ARG uid=1000
ARG gid=1000

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

RUN 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 \
&& groupadd -g ${gid} ${group} \
&& useradd -u ${uid} -g ${group} -m -s /bin/bash ${user} \
&& yum clean all -y \
&& rm -rf /var/cache/yum



FROM base AS build

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

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 . /opt/emissary
RUN chown -R ${user}:${group} /opt/emissary \
&& chmod -R 744 /opt/emissary \
&& (rm -f .mvn-classpath || true)

USER ${user}
WORKDIR /opt/emissary
RUN --mount=type=cache,uid=${uid},gid=${gid},target=/home/${user}/.m2 \
mvn -V -B -e -ntp "-Dstyle.color=always" clean verify -Pdist


FROM base

COPY --from=build /opt/emissary/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 /opt/emissary" \
&& ln -s /opt/${version} /opt/emissary \
&& mkdir -p /opt/emissary/localoutput \
&& mkdir -p /opt/emissary/target/data \
&& chmod -R a+rw /opt/emissary \
&& chown -R ${user}:${group} /opt/emissary* \
&& rm -f /tmp/*

USER ${user}

WORKDIR /opt/emissary

VOLUME /opt/emissary/target/data
VOLUME /opt/emissary/localoutput

EXPOSE 8001

ENTRYPOINT ["./emissary"]

CMD ["server", "-a", "2", "-p", "8001"]

0 comments on commit 4c24a5c

Please sign in to comment.