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

ioc: reorder stages to improve portability. #9

Merged
merged 1 commit into from
Aug 15, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ ARG DEBIAN_VERSION=11.7

FROM ghcr.io/cnpem/lnls-debian-11-epics-7:${BUILD_STAGE_VERSION} AS build-stage

ARG JOBS=1
ARG REPONAME
ARG RUNDIR
ARG BUILD_PACKAGES

RUN if [ -n "$BUILD_PACKAGES" ]; then apt update && apt install $BUILD_PACKAGES; fi
Expand All @@ -17,21 +15,8 @@ COPY . .
RUN cp /opt/epics/RELEASE configure/RELEASE


FROM build-stage AS static-build

RUN echo STATIC_BUILD=YES >> configure/CONFIG_SITE.local

RUN make distclean && make -j ${JOBS} && make clean && make -C ${RUNDIR}


FROM build-stage AS dynamic-build

RUN make distclean && make -j ${JOBS} && make clean && make -C ${RUNDIR}


FROM debian:${DEBIAN_VERSION}-slim as base

ARG REPONAME
ARG RUNDIR
ARG ENTRYPOINT=/bin/bash
ARG RUNTIME_PACKAGES
Expand All @@ -53,11 +38,31 @@ RUN ln -s ${ENTRYPOINT} ./entrypoint
ENTRYPOINT ["./entrypoint"]


FROM build-stage AS dynamic-build

ARG JOBS=1
ARG RUNDIR

RUN make distclean && make -j ${JOBS} && make clean && make -C ${RUNDIR}


FROM base AS dynamic-link

COPY --from=dynamic-build /opt /opt


FROM build-stage AS static-build

ARG JOBS=1
ARG RUNDIR

RUN echo STATIC_BUILD=YES >> configure/CONFIG_SITE.local

RUN make distclean && make -j ${JOBS} && make clean && make -C ${RUNDIR}


FROM base AS static-link

ARG REPONAME

COPY --from=static-build /opt/${REPONAME} /opt/${REPONAME}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ you **need** to link them dynamically, you must define the build target as
dependencies will also be copied.

Some Docker versions don't use
[BuildKit](https://docs.docker.com/build/buildkit/) by default, and it is
necessary to enable it, for instance, by exporting `DOCKER_BUILDKIT=1` when
building the IOC image, because the classic builder goes through all stages
even when they are not needed or are known to fail.
[BuildKit](https://docs.docker.com/build/buildkit/) by default, and it can be
more efficient to enable it, for instance, by exporting `DOCKER_BUILDKIT=1`
when building the IOC image, because the classic builder goes through all
stages even when they are not needed.

Additional build and runtime packages to be installed can be listed in `args`,
under the `BUILD_PACKAGES` and `RUNTIME_PACKAGES` keys, respectively. It is not
Expand Down