Problem with building WordPress Dockerfile - not copying wp-content directory

sarzixon
PRO

8 months ago

project ID: 0be14315-9da9-49bc-b246-f1ec0bd7cfad

I have a problem with deployment of Wordpress project.
It has two services - MySQL database and WordPress service build from Github repository.

I have created a Dockerfile for a WordPress Service:

FROM wordpress:6.6.1-php8.2

COPY wp-content/ ./wp-content

RUN chown -R www-data:www-data /var/www/html/wp-content
RUN find /var/www/ -type d -exec chmod 0755 {} \;
RUN find /var/www/ -type f -exec chmod 644 {} \;

The problem is that the Docker does not copy wp-content directory to container while deploying to Railway. Why is that? How can I fix this? The wp-content directory is present in github repository.
It works fine on local env.

0 Replies

sarzixon
PRO

8 months ago

I've found something in docs: https://docs.railway.app/guides/volumes
*Volume Availability
Volumes are mounted to your service's container when it is started, not during build time.

If you write data to a directory at build time, it will not persist on the volume, even if it writes to the directory to which you have mounted the volume.

Volumes are not mounted as overlays.*

So I need to copy the directory to Docker image from my repository during the build, how can I overcome that?


8 months ago

copy it during runtime


sarzixon
PRO

8 months ago

How?


8 months ago

the same way you are doing it during build, just do it during runtime


sarzixon
PRO

8 months ago

Could you please show me an example how can I copy wp-content directory from github repository to my volume during runtime?


sarzixon
PRO

8 months ago

It works when I detached the volume from WordPress Service…


sarzixon
PRO

8 months ago

But that does not satisfy me, because someone might upload an image to the directory and after deployment it will be erased


sarzixon
PRO

8 months ago

Since my Docker image run as non root user, I have added a variable RAILWAYRUNUID=0 to my service but application still cannot write to the volume.