GithubHelp home page GithubHelp logo

ankitasaxena17 / docker-compose-drupal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mogtofu33/docker-compose-drupal

0.0 1.0 0.0 4.96 MB

Drupal Docker Compose dev stack.

CSS 0.23% PHP 82.19% JavaScript 8.36% VCL 3.77% Shell 5.45%

docker-compose-drupal's Introduction

Drupal 8 Docker Development

Require

Introduction

Focus on simple set-up, based on Docker official images and lightweight Alpine Linux to ease maintenance.

Include

Every service is optional as declared in the yml file.

Optional Php Tools

Quick launch new Drupal 8 project

# Clone this project.
git clone https://github.com/Mogtofu33/docker-compose-drupal.git docker-drupal
cd docker-drupal

# Create your docker compose file from template.
cp docker-compose.tpl.yml docker-compose.yml

# (Optional) choose a db, remove or add services, add your composer cache folder.
# But you can let it as it for a default quick stack.
vi docker-compose.yml

# Create your config file from template.
cp default.env .env

# Edit your configuration if needed, recommended on Unix add your local uid/gid.
vi .env

# Check the config and fix if needed.
docker-compose config

# For an existing Drupal 8 project, create folders and copy it in
# Note that based on Composer template you we root should be under _drupal/web_
# folder. If not you need to adapt Apache vhost config from config/apache/vhost.conf
mkdir -p data/www/drupal
cp -r _YOUR_DRUPAL_ data/www/drupal/

# Launch the containers (first time include downloading Docker images).
docker-compose up --build -d

# Quick check logs to ensure startup is finished, mostly Apache.
docker-compose logs apache

Note: If you have a permission denied from now it's because of owner of /var/run/docker.sock, run docker and docker-compose commands as sudo.

Access the stack dashboard and your Drupal root

http://localhost
http://localhost:8181

If you have copy an existing Drupal project, you can import the database from the adminer link in the dashboard.

Setup Drupal 8 with Composer

Code download

Setup a new Drupal 8 based on a composer template (yes it's slower, but this is the good way!) with user Apache.

Based on Drupal 8 template, include Drush and Drupal console, using Composer in the docker service:

docker exec -it -u apache dcd-php \
composer create-project drupal-composer/drupal-project:8.x-dev /var/www/localhost/drupal --stability dev --no-interaction

OR locally if you have Composer, from this project root:

composer create-project drupal-composer/drupal-project:8.x-dev data/www/drupal --stability dev --no-interaction

Install Drupal 8

To use PostGresSQL change mysql to pgsql

docker exec -it -u apache dcd-php /var/www/localhost/drupal/vendor/bin/drush -y si \
--root=/var/www/localhost/drupal/web \
--account-name=admin \
--account-pass=password \
--db-url=mysql://drupal:drupal@mysql/drupal

Access your Drupal 8

http://localhost
# Login with admin / password
http://localhost/user/login

Daily usage, add some modules

docker exec -it -u apache dcd-php \
composer -d=/var/www/localhost/drupal require \
drupal/admin_toolbar drupal/ctools drupal/pathauto drupal/token drupal/panels

Daily usage, enable some modules

docker exec -it -u apache dcd-php \
/var/www/localhost/drupal/vendor/bin/drush -y en \
--root=/var/www/localhost/drupal/web \
admin_toolbar ctools ctools_block ctools_views panels token pathauto

Daily usage, run a command on the server

docker exec -it -u apache dcd-php \
ls -lah /var/www/localhost/drupal

Login in the Apache to run commands

docker exec -it -u apache dcd-php bash

Reset the stack

Destroy containers (data/ is persistent, so you are not loosing db or files)

docker-compose stop && docker-compose down

Remove your persistent data (and lost everything!)

rm -rf data

Suggested tools

You can find a script in scripts/get-tools.sh folder to download or update all tools.

cd THIS_PROJECT/scripts/
chmod +x get-tools.sh
./get-tools.sh

Troubleshooting

When accessing http://localhost:8181/ error:

Fatal error: Uncaught Http\Client\Socket\Exception\ConnectionException: Permission denied in phar:///var/www/dashboard/dashboard.phar/vendor/php-http/socket-client/src/Client.php:114...

Solution, fix local /var/run/docker.sock permission to local user:

chown $USER:$USER /var/run/docker.sock

docker-compose-drupal's People

Contributors

mogtofu33 avatar

Watchers

 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.