I am new to Docker trying to Dockerize simple lumen app locally.
Dockerfile:
FROM php:8.1 as php
WORKDIR /var/www
COPY ./ /project
COPY . .
COPY --from=composer:2.4.2 /usr/bin/composer /usr/bin/composer
docker-composer.yml:
version: "20.10"
services:
# PHP Service
php:
build:
context: .
target: php
args:
- APP_ENV=${APP_ENV}
environment:
- APP_ENV=${APP_ENV}
- CONTAINER_ROLE=app
working_dir: /var/www
volumes:
- ./:/var/www
ports:
- 8000:8000
# Libre Office Service
libreoffice:
image: lscr.io/linuxserver/libreoffice:latest
container_name: libreoffice
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
volumes:
- ./:/var/www
ports:
- 3000:3000
restart: unless-stopped
Everything works fine but I can't copy my project to custom directory in libreoffice container.
When I access libreoffice container with docker exec -it libreoffice /bin/bash I can't see project directory here. But in /var/www directory there is all directories that is in my local computer.
You may question why you are trying to copy your project to different directory?
Because I am running following command in libreoffice container:
docker exec libreoffice soffice --headless --invisible --convert-to pdf --outdir "var/www/PhpstormProjects/document-converter/public/tmp" "var/www/PhpstormProjects/document-converter/public/tmp/hi.docx"
But in this commannd I don't want to specify my path like var/www/PhpstormProjects/document-converter/public/tmp.
Because when I upload it to the live server the directory will change and it will not work properly. Means each time I change project path, I will need to change path in code as well.
Please let me know what I am doing wrong or another way I can do it.
/projectis declared in the Dockerfile you use for the 'php' service. Has nothing to do with your local setup. Also you copy the same files twice: to/projectand to/var/wwwin the php service. Doesn't really make sense/projectfolder? In which service I have to do it? As I said I am new to docker so I need exact solution for my issue.