Skip to content

Commit

Permalink
Issue RotherOSS#32: store the cpanfile in git
Browse files Browse the repository at this point in the history
Bust the Docker cache only after the dependencies have been installed
  • Loading branch information
bschmalhofer committed May 19, 2020
1 parent 00263eb commit 4d52a0a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cpanfile
.git*
.ssh
build.log
Expand Down
19 changes: 9 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
# See: https://github.com/juanluisbaptiste/docker-otrs/
# See: http://not403.blogspot.com/search/label/otrs
# See: https://forums.docker.com/t/command-to-remove-all-unused-images
# See: https://www.docker.com/blog/intro-guide-to-dockerfile-best-practices/
# See: https://stackoverflow.com/questions/34814669/when-does-docker-image-cache-invalidation-occur

# Here are some commands for Docker newbys:
# show version: sudo docker version
# build an image: sudo docker build -t otobo-plack .
# build an image: sudo docker build --tag otobo-plack .
# run the new image: sudo docker run -p 5000:5000 -v opt_otobo:/opt/otobo otobo-plack
# log into the new image: sudo docker run -v opt_otobo:/opt/otobo -it otobo-plack bash
# show running images: sudo docker ps
Expand All @@ -31,20 +33,17 @@ RUN cpanm --force Net::Server

# The modules in /opt/otobo/Kernel/cpan-lib are not considered by cpanm.
# This hopefully reduces potential conflicts.
# create /opt/otobo and use it as working dir
COPY bin ./bin
COPY Kernel ./Kernel
RUN pwd
RUN echo 'axxx' && tree
RUN (./bin/otobo.CheckModules.pl --cpanfile > cpanfile) \
&& cpanm --with-feature plack --with-feature=mysql --installdeps .

FROM otobo-install-dependencies AS otobo-plack
# A minimal copy so that the Docker cache is not busted
COPY cpanfile ./cpanfile
RUN cpanm --with-feature plack --with-feature=mysql --installdeps .

# create /opt/otobo and use it as working dir
RUN mkdir /opt/otobo
COPY . /opt/otobo
WORKDIR /opt/otobo

# TODO: configure cron

# start the webserver
# TODO: call run.sh that also calls Cron.sh
CMD plackup --server Starman --port 5000 bin/psgi-bin/otobo.psgi
9 changes: 9 additions & 0 deletions bin/otobo.CheckModules.pl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
# Modules that are required are marked by setting 'Required' to 1.
# Dependent packages can be declared by setting 'Depends' to a ref to an array of hash refs.
# The key 'Features' is only used for supporting features when creating a cpanfile.
#
# ATTENTION: when makeing changes here then make sure that you also regenerate the cpanfile
# bin/otobo.CheckModules.pl --cpanfile > cpanfile
my @NeededModules = (
{
Module => 'Apache::DBI',
Expand Down Expand Up @@ -716,6 +719,12 @@
);

if ($DoPrintCpanfile) {
say <<'END_HEADER';
# Do not change this file manually.
# Instead adapt bin/otobo.CheckModules.pl and call
# ./bin/otobo.CheckModules.pl --cpanfile > cpanfile
END_HEADER

PrintCpanfile( \@NeededModules, 1, 1 );
}
elsif ($DoPrintPackageList) {
Expand Down
45 changes: 45 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Do not change this file manually.
# Instead adapt bin/otobo.CheckModules.pl and call
# ./bin/otobo.CheckModules.pl --cpanfile > cpanfile

requires 'Archive::Tar';
requires 'Archive::Zip';
requires 'Date::Format';
requires 'DateTime';
requires 'DBI';
requires 'Digest::SHA';
requires 'List::Util::XS';
requires 'LWP::UserAgent';
requires 'Net::DNS';
requires 'Template::Toolkit';
requires 'Template::Stash::XS';
requires 'Time::HiRes';
requires 'XML::LibXML';
requires 'YAML::XS';

feature 'mysql', 'Support for database MySQL' => sub {
requires 'DBD::mysql';
};

feature 'odbc', 'Support for database access via ODBC' => sub {
requires 'DBD::ODBC';
};

feature 'oracle', 'Support for database Oracle' => sub {
requires 'DBD::Oracle';
};

feature 'plack', 'Suppport for plack' => sub {
requires 'CGI::Emulate::PSGI';
requires 'Moo';
requires 'Plack';
requires 'Plack::App::File';
requires 'Plack::Middleware::Header';
requires 'Plack::Middleware::ForceEnv';
requires 'SOAP::Transport::HTTP::Plack';
requires 'Starman';
};

feature 'postgresql', 'Support for database PostgreSQL' => sub {
requires 'DBD::Pg';
};

0 comments on commit 4d52a0a

Please sign in to comment.