Skip to content

Commit

Permalink
Update backend-dev to use the same copy mechanism as backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
hangy committed Sep 26, 2018
1 parent 8e9aa06 commit e9172e4
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions docker/backend-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,57 @@ RUN apk add alpine-sdk imagemagick6 imagemagick6-dev graphviz graphviz-dev tesse
# As of Alpine 3.7, zbar is only available in testing.
RUN apk add imagemagick@edge zbar@testing zbar-dev@testing

WORKDIR /tmp

# Dependency of libapreq2-2.13, which is not installed automatically.
RUN cpm install ExtUtils::XSBuilder::ParseSource -g
RUN cpm install ExtUtils::XSBuilder::ParseSource

# Builder image stage
ARG BRANCH
ADD https://raw.githubusercontent.com/openfoodfacts/openfoodfacts-server/${BRANCH}/cpanfile /tmp/cpanfile-git

# Add ProductOpener runtime dependencies from the git repositories' cpanfile (speeds up builds if stuff up to here has not changed)
RUN cpm install -g --cpanfile=/tmp/cpanfile-git
RUN cpm install --cpanfile=/tmp/cpanfile-git

# Install cpanfile from the workdir.
ADD ./cpanfile "/tmp/cpanfile-workdir"

# Add ProductOpener runtime dependencies from the local cpanfile
RUN cpm install -g --cpanfile=/tmp/cpanfile-workdir
RUN cpm install --cpanfile=/tmp/cpanfile-workdir

FROM hangy/httpd-alpine-perl-modperl

# Remove APK cache
RUN set -x \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/*

# As of Alpine 3.7, zbar is only available in testing.
RUN echo -e '@edge http://dl-cdn.alpinelinux.org/alpine/edge/main\n@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community\n@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories

# Update alpine package index
RUN apk update

RUN apk add imagemagick6 graphviz tesseract-ocr geoip \
&& /etc/periodic/monthly/geoip \
&& ln -s /usr/share/GeoIP /usr/local/share/GeoIP

# As of Alpine 3.7, zbar is only available in testing.
RUN apk add imagemagick@edge zbar@testing

# Prepare Apache to include our custom config
RUN set -x \
&& mkdir -p /usr/local/apache2/conf/sites-enabled \
&& echo 'IncludeOptional conf/sites-enabled/*.conf' >> /usr/local/apache2/conf/httpd.conf

# Get GeoIP data
COPY --from=builder /usr/share/GeoIP /usr/share/GeoIP
RUN ln -s /usr/share/GeoIP /usr/local/share/GeoIP

# Copy Perl binaries and libraries from the builder image
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY --from=builder /usr/local/share/perl5/site_perl/ /usr/local/share/perl5/site_perl/

# Install Product Opener from the workdir
ADD . "/opt/product-opener/"
WORKDIR "/opt/product-opener"

# Copy Perl libraries from the builder image
COPY --from=builder /tmp/local/ /opt/product-opener/local/

# Remove APK cache
RUN set -x \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/*

0 comments on commit e9172e4

Please sign in to comment.