R
Railwayβ€’14mo ago
sheffikthegod

Build from Dockerfile doesn't start

Hey. Hey, I've been struggling with this for over 8 hours, so far I can't deploy my Laravel/Svelte/Inertia application anywhere. At first I wanted to use docker-compose.yml and host it on Azure, after failing to set it up I reverted to just Dockerfile and Railway. Unfortunately, when I try to build the application and deploy to Railway, the build just won't start, even though Railway found my dockerfile. Does anyone have any idea why this isn't working? Dockerfile
# We use the official PHP image with Apache
FROM php:8.1-apache

# Install the necessary tools and extensions
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
&& docker-php-ext-install zip

# Install the necessary PHP extension
RUN docker-php-ext-install pdo_mysql

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Activate mod_rewrite for Apache
RUN a2enmod rewrite

# Set up the working directory
WORKDIR /var/www/html

# Copy Composer dependencies
COPY composer.json composer.lock ./

# Install Composer dependencies
RUN composer install --no-scripts --no-autoloader --no-dev --prefer-dist

# Copy the NPM dependencies
COPY package.json ./

# Install NPM dependencies
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
RUN npm install

# Copy the rest of the application
COPY . .

# Generate the autoloader and start the migration
RUN composer dump-autoload --optimize

# Build the frontend
RUN npm run prod

# Set permissions
RUN chown -R www-data:www-data /var/www/html

# Set Apache DocumentRoot to Laravel's public directory
RUN sed -i 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/000-default.conf

# Expose port 80
EXPOSE 80
# We use the official PHP image with Apache
FROM php:8.1-apache

# Install the necessary tools and extensions
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
&& docker-php-ext-install zip

# Install the necessary PHP extension
RUN docker-php-ext-install pdo_mysql

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Activate mod_rewrite for Apache
RUN a2enmod rewrite

# Set up the working directory
WORKDIR /var/www/html

# Copy Composer dependencies
COPY composer.json composer.lock ./

# Install Composer dependencies
RUN composer install --no-scripts --no-autoloader --no-dev --prefer-dist

# Copy the NPM dependencies
COPY package.json ./

# Install NPM dependencies
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
RUN npm install

# Copy the rest of the application
COPY . .

# Generate the autoloader and start the migration
RUN composer dump-autoload --optimize

# Build the frontend
RUN npm run prod

# Set permissions
RUN chown -R www-data:www-data /var/www/html

# Set Apache DocumentRoot to Laravel's public directory
RUN sed -i 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/000-default.conf

# Expose port 80
EXPOSE 80
Lots of love Luka
21 Replies
Percy
Percyβ€’14mo ago
Project ID: 155248f7-afe3-42dd-a929-db4f95caa1b6
sheffikthegod
sheffikthegodβ€’14mo ago
155248f7-afe3-42dd-a929-db4f95caa1b6
saintcore
saintcoreβ€’14mo ago
Delay in Build & Deploy logs visibility – Incident details - Railwa...
Delay in Build & Deploy logs visibility – Incident details - Railway Status
sheffikthegod
sheffikthegodβ€’14mo ago
I see, guess I'll have to wait to be sure haha.
saintcore
saintcoreβ€’14mo ago
I do think there is more going on under the hood then just a delay in logs-visibility. There are plenty users reporting that their (once working) deploys are failing since today (including myself) without any changes to their code^^ @sheffik The build logs error should be fixed and at least for me my build error has also somehow magically gone away πŸ˜„
sheffikthegod
sheffikthegodβ€’14mo ago
I'll check it out! Thanks
sheffikthegod
sheffikthegodβ€’14mo ago
sheffikthegod
sheffikthegodβ€’14mo ago
sadly nothing yet nvm something is happening just took a long time
saintcore
saintcoreβ€’14mo ago
Wait a few seconds/minutes, there seems to be a delay with displaying them. In my case my deployment (build) was already running for 2mins until logs were showing up yep πŸ˜„
sheffikthegod
sheffikthegodβ€’14mo ago
yeah I guess it works now
sheffikthegod
sheffikthegodβ€’14mo ago
another problem popped up tho haha
sheffikthegod
sheffikthegodβ€’14mo ago
but I guess that's on my side
Adam
Adamβ€’14mo ago
Looks like you've got it, but I do want to note that docker compose is not supported by Railway atm
sheffikthegod
sheffikthegodβ€’14mo ago
As a guy who does mainly React/Nuxt, I would've never guessed that deploying a web app could take this long lmao
Adam
Adamβ€’14mo ago
it requires persistent storage, which Railway does not support
sheffikthegod
sheffikthegodβ€’14mo ago
I am not using docker-compose tho
Adam
Adamβ€’14mo ago
You were, you said so in your first message just wanted to clear that up
sheffikthegod
sheffikthegodβ€’14mo ago
Yeah, I switched up back to just docker, cause I wanted to deploy on railway but I honestly can't wrap my head around this
saintcore
saintcoreβ€’14mo ago
Hmm I'm wondering why you do build the docker image (if using nuxt for example) by yourself? IMHO Railway does a great job when letting them handle this step for you. At least for me (but I'm working at the backend part and almost all my projects are running with strapi)
sheffikthegod
sheffikthegodβ€’14mo ago
I am building a Laravel/Svelte app this is a nightmare tbh haha I got rid of the previous error AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.203. Set the 'ServerName' directive globally to suppress this message this is the last thing standing in my path I guess
Brody
Brodyβ€’14mo ago
like saintcore said, why not let nixpacks build your app?