Created
June 7, 2017 03:58
-
-
Save brucecrevensten/d833d7ea52514834a5411439b2dc430d to your computer and use it in GitHub Desktop.
Sketch for SNAP Drupal Docker build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Local development instance with Docker | |
### Setup Docker containers | |
1. Install [Docker](https://www.docker.com/) if you have not already. | |
1. Grab database and files and save them to your `~/Downloads` folder as `snapdb.sql` and `files.bz2` respectively. | |
1. Download [Drupal 7](https://ftp.drupal.org/files/projects/drupal-7.54.tar.gz) to `~/Downloads`. | |
1. Prepare some directories, files, and the SNAP web repository: | |
```bash | |
mkdir -p ~/docker-snap | |
cd ~/docker-snap | |
cp ~/Downloads/drupal-7.54.tar.gz . && tar -zxvf drupal-7.54.tar.gz | |
mv drupal-7.54 drupal-core | |
cd drupal-core/sites | |
git clone https://github.com/ua-snap/snap-drupal.git | |
mv snap-drupal all | |
cd ~/docker-snap/drupal-core/sites/default | |
tar -jxvf ~/Downloads/files.bz2 | |
chmod -R 777 files | |
``` | |
1. Download Drupal settings file that reads MySQL host and root password from Docker environment variables. | |
```bash | |
cd ~/docker-snap/drupal-core/sites/default | |
curl -O 'https://raw.githubusercontent.com/ua-snap/docker-drupal-settings/master/settings.php' | |
``` | |
1. Set up persistent MySQL database container. **Note:** you may need to wait 10-20 seconds after this command returns before you can connect to the MySQL server in the next step. | |
```bash | |
docker run --name snap-mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:latest | |
``` | |
1. Spawn temporary container that links to MySQL container and creates database. | |
```bash | |
docker run -it --link snap-mysql:mysql --rm mysql sh -c 'exec mysql \-h "$MYSQL_PORT_3306_TCP_ADDR" -P "$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -e "CREATE DATABASE drupal7;"' | |
``` | |
1. Spawn temporary container that links to MySQL container and imports database dump. | |
```bash | |
docker run -i --link snap-mysql:mysql --rm mysql sh -c 'exec mysql \-h "$MYSQL_PORT_3306_TCP_ADDR" -P "$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" drupal7' < ~/Downloads/snapdb.sql | |
``` | |
1. Set up persistent Drupal container that links to MySQL container. | |
```bash | |
docker run --name snap-drupal -p 8080:80 --link snap-mysql:mysql -v ~/docker-snap/drupal-root:/var/www/html -d drupal:7 | |
``` | |
At this point, the SNAP website should be available locally at `http://localhost:8080`. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment