I am working on app that has a webserver running openresty and a application running on php wit the front-end in vue.
version: '3' services: php: build: ./ volumes: - ./services/php/php.ini:/usr/local/etc/php/php.ini web: build: ./services/openresty ports: - "8888:80" volumes: - ./services/openresty/company.conf:/usr/local/openresty/nginx/conf/nginx.conf - ./services/openresty/bodyconfig.conf:/etc/openresty/nginx/conf/bodyconfig.conf When building the application I am building my vue code to a dist folder this happens inside the php container:
FROM php:7.3-fpm-alpine RUN apk update \ && apk add --no-cache git curl libmcrypt libmcrypt-dev openssh-client icu-dev \ libxml2-dev bash freetype-dev libpng-dev libjpeg-turbo-dev nodejs npm libzip-dev g++ make autoconf postgresql-dev \ && docker-php-source extract \ && pecl install redis \ && docker-php-ext-enable redis \ && docker-php-source delete \ && docker-php-ext-install pdo_pgsql soap intl gd zip \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ && rm -rf /tmp/* CMD ["php-fpm", "-F"] WORKDIR /var/www/company COPY ./ ./ RUN bash ./docker_build.sh EXPOSE 9000 docker_build.sh
cd /var/www/company/js npm install npm run build now inside the php docker container is a new folder dist under /var/www/dist.
nginx needs to use this folder because it contains a static index.html which is served by nginx like this
location / { alias /var/www/company/dist/; try_files $uri $uri/ /index.html; } I am wondering how I can my web container access the build folder dist which is located inside the php container
Thanks in advance
servicessection of the docker-compose file, you need to add avolumessection, define a volume and map that volume to both the services. Take a look at this