Skip to content

Commit

Permalink
Issue #3617: run `carton install --deployment' for non-local builds
Browse files Browse the repository at this point in the history
Currently the distinction is based on whether $DOCKER_TAG starts with 'local-'.
Use the nifty heredoc syntac for complex bash commands
  • Loading branch information
bschmalhofer committed Jul 17, 2024
1 parent 399bc9b commit 4e56eeb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
!CONTRIBUTING.md
!COPYING-Third-Party
!cpanfile.docker
!cpanfile.docker.snapshot
!cpanfile.docker.kerberos
!INSTALL.md
!LICENSE
Expand Down
1 change: 0 additions & 1 deletion cpanfile.docker.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -3239,7 +3239,6 @@ DISTRIBUTIONS
Parse::RecDescent::Token 1.967015
Parse::RecDescent::UncondReject 1.967015
requirements:
ExtUtils::MakeMaker 6.5702
Test::More 0
Text::Balanced 1.95
Path-Class-0.37
Expand Down
1 change: 1 addition & 0 deletions hooks/build
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ TARGET_OPTION=$(case $DOCKERFILE_PATH in
esac)

# build the Docker image
# add the option '--progress plain' for seeing the printed output
docker build\
--build-arg "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"\
--build-arg "DOCKER_TAG=$DOCKER_TAG"\
Expand Down
23 changes: 18 additions & 5 deletions otobo.web.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,31 @@ ENV LANG=C.UTF-8
# Note that the modules in /opt/otobo/Kernel/cpan-lib are not considered by cpanm.
# This hopefully reduces potential conflicts.
#
# carton install will create cpanfile.snapshot. Currently this file is only used for documentation.
# 'carton install' will update cpanfile.snapshot.
# 'carton install --deployment' will install the exact versions from cpanfile.snapshot.
#
# Note that the variable $DOCKER_TAG is already substituted by Docker.
#
# Clean up the .cpanm dir after the installation tasks as that dir is no longer needed
# and the unpacked Perl distributions sometimes have weird user and group IDs.
WORKDIR /opt/otobo_install
COPY cpanfile.docker cpanfile
COPY cpanfile.docker.snapshot cpanfile.snapshot
ENV PERL5LIB="/opt/otobo_install/local/lib/perl5"
ENV PATH="/opt/otobo_install/local/bin:${PATH}"
RUN cpanm --local-lib local Carton\
&& PERL_CPANM_OPT="--local-lib /opt/otobo_install/local" carton install\
&& rm -rf "/root/.cpanm"
ARG DOCKER_TAG=unspecified
RUN <<END_BASH bash
set -eux
PERL_CPANM_OPT="--local-lib /opt/otobo_install/local"
cpanm --local-lib local Carton
if [[ $DOCKER_TAG == local-* ]]
then
carton install
else
carton install --deployment
fi
rm -rf "/root/.cpanm"
END_BASH

# Add some additional meta info to the image.
# This done at the end of the Dockerfile as changed labels and changed args invalidate the layer cache.
Expand Down Expand Up @@ -200,7 +214,6 @@ ARG BUILD_DATE=unspecified
LABEL org.opencontainers.image.created=$BUILD_DATE
LABEL org.opencontainers.image.revision=$GIT_COMMIT
LABEL org.opencontainers.image.source=$GIT_REPO
ARG DOCKER_TAG=unspecified
LABEL org.opencontainers.image.version=$DOCKER_TAG

# This Dockerfile also provides for building images with additional support for Kerberos.
Expand Down

0 comments on commit 4e56eeb

Please sign in to comment.