Is it possible to copy one stage of a multi-stage Dockerfile into another?
For various business reasons I have been instructed to use a multi-stage Dockerfile, but what I really need to do is combine the appserver image and webserver image. This is fine in docker-compose as you can reference each section - but I am not sure if this can be done over GCP and Kubernetes.
My Dockerfile code is below.
FROM php:7.1-fpm as appserver
RUN apt-get update && apt-get install -y libpq-dev \
&& docker-php-ext-install pdo pdo_pgsql pgsql
RUN apt-get update && \
apt-get install -y \
zlib1g-dev \
&& docker-php-ext-install zip
COPY ./app /var/www/html
FROM nginx:stable-alpine as webserver
COPY ./app /var/www/html/
COPY vhost-prod.conf /etc/nginx/conf.d/default.conf
Not sure, what are you trying to achieve by your Dockerfile above.
For your use case , please make two docker files , one for the app, and other for proxy/nginx , build them independently and run/scale them independently.
In case of static content serving from nginx , you just need to run nginx with volume mount of static content.