0

Currently , i need to build a custom image that should contain jenkins and php 7.2 .

I have tried this shot :

FROM jenkins/jenkins:lts as jenkins

USER root

ARG TIMEZONE
# update
RUN apt update

# dependencies
RUN apt install -qqy  \
    tzdata \
    wget \
    curl \
    ...

# Timezone
RUN echo "Europe/Paris" > /etc/timezone



FROM php:7.2-apache

WORKDIR /var/jenkins

COPY --from=build-env /app/_site ./

RUN apt-get update && apt-get install -y \
    openssl \
    git \
    unzip vim \
    libfreetype6-dev \
    ...

The second FROM (FROM php:7.2-apache) crush the whole above . And it's normal as docker behavior . Using the Copy command like COPY --from=jenkins /app/site ./ still blurred since there is not idea what to copy-paste .

Is there any solution to resolve that issue ?

Yassine CHABLI
  • 3,459
  • 2
  • 23
  • 43
  • Not sure if you use that staged build correctly. With the `--from` flag you cann access the intermediate container and copy files into your next image, but will not just merge the images. From your question it sounds like you want to install jenkins into `php:7.2-apache` image. To get this you need to inherit from `php:7.2-apache` add the stuff from the Dockerfile in image `jenkins`. It will add users, set correct permissions etc. – Dominik Gebhart Jun 18 '19 at 18:04
  • You mean `FROM php:7.2-apache` will make build crash? And I didn't see `/app/site` in the first build stage. And what's the error? – atline Jun 19 '19 at 01:33
  • I think what you want is a base php 7.2 image with Jenkins installed on it. Multi-stage builds are (I believe) designed to isolate processes like builds from final images. I'm not sure what your use case is or how strict it is they need to be the same image, but you might also consider spinning a separate service/container hosting Jenkins. Then you have an app container and a Jenkins container to perform separate tasks. – RoboBear Sep 18 '19 at 17:02

0 Answers0