GitHub - doorcloud/laravel · GitHub
Skip to content

Repository files navigation

Launching a Laravel (PHP) Application with Docker

This guide explains how to set up and launch a Laravel (PHP) application with Apache using Docker.

Prerequisites

Before starting, ensure you have the following tools installed on your machine:

Dockerfile Content

This Dockerfile configures a container for a Laravel (PHP) application with Apache. It installs the PHP gd extension, configures PHP to use the production environment, and installs PHP dependencies via Composer.

ARG PHP_EXTENSIONS="gd"

FROM thecodingmachine/php:8.3-v4-apache

ENV PHP_EXTENSION_GD=1
ENV TEMPLATE_PHP_INI=production

COPY .env.example .env
COPY --chown=docker:docker . /var/www/html

ENV APACHE_DOCUMENT_ROOT=public/

RUN composer install
RUN php artisan key:generate

Steps to Launch the Application

  1. Build the Docker Image

To build the Docker image, use the following command in the directory containing the Dockerfile:

docker build -t door-laravel .
  1. Run the Container

Once the image is built, run a container from this image:

docker run -p 8080:80 door-laravel
  1. Access the Application

Open your browser and go to the following URL to see your application running:

http://localhost:8080
  1. Environment Variables

If you need to configure additional environment variables, modify the .env file that was copied into the container during the image build.

Publishing the Image on Docker Hub

  1. Log In to Docker Hub

Before publishing your image, log in to Docker Hub with your Docker account:

docker login
  1. Tag the Image

Tag the image you built with your Docker Hub username and the image name:

docker tag door-laravel your_dockerhub_username/door-laravel:latest

Replace your_dockerhub_username with your Docker Hub username.

  1. Push the Image to Docker Hub

Push the tagged image to Docker Hub:

docker push your_dockerhub_username/door-laravel:latest

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages