Git Product home page Git Product logo

php-docker's Introduction

php-docker

php-docker is a simple docker-compose orchestration that sets up a three- container network for local PHP development (Laravel, Symfony, Slim, etc). With this repo, you get:

  • PHP container
    • Builds custom from php:7.4-fpm-alpine
    • Adds a bunch* of PHP extensions
    • Installs curl, vim, and composer for convenience
    • Maps ./src to /var/www
    • Uses PHP-FPM running on :9000
  • Nginx container
    • Uses nginx:latest
    • Supports use of mkcert for local SSL (see SSL below)
    • Listens on port 80 (for convenience)
  • Mariadb container
    • Uses mariadb:latest
    • Stores data in ./mariadb/
    • Inits from vars in docker-compose.yml

* see Dockerfile

Usage

  1. Install Docker CE

  2. Install Docker Compose

  3. Clone this repository

git clone https://github.com/mccheesy/php-docker.git`
  1. Either copy your existing PHP application source to the src directory or create a new project. Since you have Docker installed, you can create a new Laravel project using the Composer container thus:
docker run --rm --it \
    --volume $PWD:/app \
    --user $(id -u):$(id -g) \
    composer create-project --prefer-dist laravel/laravel src
  1. Build and run the containers (in detached mode)
docker-compose up -d

For SSL [Optional]

  1. Install mkcert

  2. Create cert files for https://app.test. For example:

mkcert -install
mkcert app.test "*.app.test"
mv *.pem ./nginx/ssl/
  1. Edit line 50 of docker-compose.yml: change server.conf to server-ssl.conf

  2. Rebuild the Nginx container

docker-compose up -d --build nginx

Hosts

If you are used to something like Valet, this can be a little tedious. I just use the same test domain (app.test) for all my sites and keep only one of these container networks running at a time.

If you have a need to add multiple subdomains or domains, you will just need to adjust your hosts file and the Nginx/docker-compose files and rebuild the containers.

Contact

I do not claim to be an expert on Docker, Docker Compose, or container orchestration, but if you have any questions or run into any issues, I'm happy to offer whatever help I can supply. I can be reached via email at [email protected].

php-docker's People

Contributors

mccheesy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.