Skip to content

Commit 174be27

Browse files
committed
Change to use metacpan-base
Instead of using a base perl docker image, use the new metacpan-base image and build the api upon that. The result should be faster build times and smaller images. Environment variables have been introduced for being able to switch the server that is being executed in the image. Those variables are set in the `.env` file.
1 parent 11bc12a commit 174be27

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PGDB=db:5432
2+
API_SERVER=morbo -l http://*:5000 -w /metacpan-api --verbose

Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
FROM perl:5.22
1+
FROM metacpan/metacpan-base:latest
22

33
ENV PERL_MM_USE_DEFAULT=1 PERL_CARTON_PATH=/carton
44

5-
COPY wait-for-it.sh /
65
COPY cpanfile cpanfile.snapshot /metacpan-api/
76
WORKDIR /metacpan-api
87

9-
RUN apt-get update \
10-
&& apt-get install -y libgmp-dev rsync \
11-
&& cpanm App::cpm \
12-
&& cpm install -g Carton \
13-
&& useradd -m metacpan-api -g users \
8+
# CPM installations of dependencies does not install or run tests. This is
9+
# because the modules themselves have been tested, and the metacpan use of the
10+
# modules is tested by the test suite. Removing the tests, reduces the overall
11+
# size of the images.
12+
RUN useradd -m metacpan-api -g users \
1413
&& mkdir /carton /CPAN \
15-
&& cpm install -L /carton \
14+
&& cpm install --without-test -L /carton \
1615
&& rm -fr /root/.cpanm /root/.perl-cpm /var/cache/apt/lists/* /tmp/*
1716

1817
RUN chown -R metacpan-api:users /metacpan-api /carton /CPAN
@@ -25,4 +24,4 @@ USER metacpan-api:users
2524

2625
EXPOSE 5000
2726

28-
CMD [ "/wait-for-it.sh", "db:5432", "--", "carton", "exec", "morbo", "-l", "http://*:5000", "-w", "root", "./bin/api.pl"]
27+
CMD /wait-for-it.sh ${PGDB} -- carton exec ${API_SERVER} ./bin/api.pl

0 commit comments

Comments
 (0)