Question

Error in GitLab runner Docker file

My Docker file contents:

FROM nginx:1.18
COPY index.html /usr/share/nginx/html

Gitlab Runner log error message:

Step 2/2 : COPY index.html /usr/share/nginx/html
COPY failed: file not found in build context or excluded by .dockerignore: stat index.html: file does not exist

Setup: It is laravel app. So no index.html file exists…

=== Honestly, I have no idea how to proceed… Should I rename COPY public/index.php

Thx!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
September 2, 2022

Hi there,

Indeed, the Dockerfile that you are currently using is for a static HTML website with a single index.html file.

As you are using Laravel, you need to create a Dockerfile that installs all of your dependencies, for example:

# Set the base image for subsequent instructions
FROM php:7.4

# Update packages
RUN apt-get update

# Install PHP and composer dependencies
RUN apt-get install -qq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev

# Clear out the local repository of retrieved package files
RUN apt-get clean

# Install needed extensions
# Here you can install any other extension that you need during the test and deployment process
RUN docker-php-ext-install mcrypt pdo_mysql zip

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

# Install Laravel Envoy
RUN composer global require "laravel/envoy=~1.0"

For more information on the GitLab runner, I could suggest the following documentation:

https://docs.gitlab.com/ee/ci/examples/laravel_with_gitlab_and_envoy/

Hope that this helps!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up