Skip to content

Instantly share code, notes, and snippets.

@jonpemby
Last active January 21, 2018 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonpemby/b79400caba5ad87d2a9d264b132201ee to your computer and use it in GitHub Desktop.
Save jonpemby/b79400caba5ad87d2a9d264b132201ee to your computer and use it in GitHub Desktop.
Starting a new Drupal project with Docker (SQLite)
#!/bin/bash
# Change directory to where you want to create your project.
# Composer's create-project command creates a project with
# a particular vendor package as the base into a provided directory
# You can change the project variable to the
# preferred folder name for your project
export project="project-name"
composer create-project drupal/drupal $project
cd $project
# Here, we get the current directory and store it in $h for our host base directory
# and we store the base directory that we want to mount our volumes to on our guest
# You can also optionally set the ports here as well.
export h=$(pwd)
export g="/var/www/html"
export host_port="8080"
export guest_port="80"
# This is where our Docker magic happens: we create a container with
# our project's name and provide mounted directories for our profiles,
# modules, themes and sites directories as recommended by the Docker Drupal image. :)
docker run --name $project -p $host_port:$guest_port -d \
-v $h/profiles:$g/profiles \
-v $h/modules:$g/modules \
-v $h/themes:$g/themes \
-v $h/sites:$g/sites \
drupal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment