gregorip02
gregorip02
RRailway
Created by gregorip02 on 8/22/2024 in #✋|help
Laravel app: permission denied to write on mounted volume
Because I'm using a docker image that by default runs as a non-privileged user www-data:www-data or 33:33, it's necessary to change the owner of the mounted volume after starting the container. To achieve this, I added a script in /etc/entrypoint.d/99-starting-hook.sh with the following content:
#!/bin/sh

# chown the mount to allow the www-data user read and write access.
chown -R 33:33 /var/www/html/storage/app/public && echo "✅ added permissions to mounted volume"

# optimize filament for production (optional).
php /var/www/html/artisan filament:optimize
#!/bin/sh

# chown the mount to allow the www-data user read and write access.
chown -R 33:33 /var/www/html/storage/app/public && echo "✅ added permissions to mounted volume"

# optimize filament for production (optional).
php /var/www/html/artisan filament:optimize
This is my final Dockerfile:
FROM serversideup/php:8.3-unit

USER root

# Install server dependencies
RUN apt-get update \
&& apt-get install -y ca-certificates gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends nodejs \
&& install-php-extensions intl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

COPY --chmod=755 ./99-starting-hook.sh /etc/entrypoint.d/99-starting-hook.sh

USER www-data

COPY --chown=www-data:www-data . .

RUN composer install --no-dev --no-interaction && \
npm ci && \
npm run build && \
rm -rf node_modules/ && \
chmod -R 777 /var/www/html/storage /var/www/html/bootstrap/cache /var/www/html/public
FROM serversideup/php:8.3-unit

USER root

# Install server dependencies
RUN apt-get update \
&& apt-get install -y ca-certificates gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends nodejs \
&& install-php-extensions intl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

COPY --chmod=755 ./99-starting-hook.sh /etc/entrypoint.d/99-starting-hook.sh

USER www-data

COPY --chown=www-data:www-data . .

RUN composer install --no-dev --no-interaction && \
npm ci && \
npm run build && \
rm -rf node_modules/ && \
chmod -R 777 /var/www/html/storage /var/www/html/bootstrap/cache /var/www/html/public
There is no need to add the RAILWAY_RUN_UID=0 environment variable because the volume is already owned by the www-data user. If you are using serversideup/php:8.3-unit you must add the following environment variable: AUTORUN_ENABLED=true This will run php artisan storage:link after starting the container.
16 replies
RRailway
Created by gregorip02 on 8/22/2024 in #✋|help
Laravel app: permission denied to write on mounted volume
The problem has been solved, I will share my solution.
16 replies
RRailway
Created by gregorip02 on 8/22/2024 in #✋|help
Laravel app: permission denied to write on mounted volume
No description
16 replies
RRailway
Created by gregorip02 on 8/22/2024 in #✋|help
Laravel app: permission denied to write on mounted volume
Can i specify RAILWAY_RUN_UID=33 to make it the same uid as the image?
16 replies
RRailway
Created by gregorip02 on 8/22/2024 in #✋|help
Laravel app: permission denied to write on mounted volume
Same problem.
16 replies
RRailway
Created by gregorip02 on 8/22/2024 in #✋|help
Laravel app: permission denied to write on mounted volume
Yes, trying...
16 replies
RRailway
Created by gregorip02 on 8/22/2024 in #✋|help
Laravel app: permission denied to write on mounted volume
FROM serversideup/php:8.3-unit

USER root

# Install server dependencies
RUN apt-get update \
&& apt-get install -y ca-certificates gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends nodejs \
&& install-php-extensions intl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Install project dependencies
COPY package*.json composer.* ./
RUN composer install --no-dev --no-autoloader --no-scripts --no-interaction && npm ci

COPY . .

RUN composer dump --no-interaction && \
npm run build && \
rm -rf node_modules && \
# find /var/www/html -type d -not -path "./vendor/*" -not -path "./.git/*" -exec chmod 755 "{}" \; && \
# find /var/www/html -type f -not -path "./vendor/*" -not -path "./.git/*" -exec chmod 644 "{}" \; && \
chmod -R 777 /var/www/html/storage /var/www/html/bootstrap/cache && \
php /var/www/html/artisan filament:optimize

USER www-data
FROM serversideup/php:8.3-unit

USER root

# Install server dependencies
RUN apt-get update \
&& apt-get install -y ca-certificates gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends nodejs \
&& install-php-extensions intl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Install project dependencies
COPY package*.json composer.* ./
RUN composer install --no-dev --no-autoloader --no-scripts --no-interaction && npm ci

COPY . .

RUN composer dump --no-interaction && \
npm run build && \
rm -rf node_modules && \
# find /var/www/html -type d -not -path "./vendor/*" -not -path "./.git/*" -exec chmod 755 "{}" \; && \
# find /var/www/html -type f -not -path "./vendor/*" -not -path "./.git/*" -exec chmod 644 "{}" \; && \
chmod -R 777 /var/www/html/storage /var/www/html/bootstrap/cache && \
php /var/www/html/artisan filament:optimize

USER www-data
16 replies
RRailway
Created by gregorip02 on 8/22/2024 in #✋|help
Laravel app: permission denied to write on mounted volume
e2d6c1c6-c741-45c3-b553-98603eaddb38
16 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
How can we mark this as solved?
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
No description
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
It just worked, I moved the "php artisan optimize" command which caches the configuration (includes the DB credentials) and maybe it was pointing to a non-existent database at the execution stage.
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
Are the env vars availables in build stage?
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
Deply logs
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
No description
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
I don't have the host resolution issue, but apparently there is a restriction for a query in the migration: SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select table_name as name, (data_length + index_length) as size, table_commentas comment, engine as engine, table_collation as collation from information_schema.tables where table_schema = 'forge' and table_type in ('BASETABLE', 'SYSTEM VERSIONED') order by table_name)
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
No description
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
Oh, i'm adding the sleep in my Dockerfile.
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
I tried it but it still has the same problem, in fact, minutes after the deployment I tried to execute: railway run sh -c "ping mysql.railway.internal" but I get: "ping: cannot resolve mysql.railway.internal: Unknown host"
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
I think it's based on debian
26 replies
RRailway
Created by gregorip02 on 3/16/2024 in #✋|help
I can't access my MySQL database using the private network.
No description
26 replies