Skip to content

Instantly share code, notes, and snippets.

@jackmcpickle
Last active July 24, 2019 19:22
Show Gist options
  • Save jackmcpickle/59efc98a99c067b08020 to your computer and use it in GitHub Desktop.
Save jackmcpickle/59efc98a99c067b08020 to your computer and use it in GitHub Desktop.
Our Craft CMS docker-compose dev setup
web:
build: .
ports:
- 80:80
volumes:
- ./log:/var/log
- ./templates:/app/craft/templates
- ./public:/app/public
links:
- redis
- mysql
environment:
# Set locale to UTF-8 (https://oncletom.io/2015/docker-encoding/)
LANG: C.UTF-8
# Redis is linked
REDIS_SERVER_HOST: redis # set fo
REDIS_SERVER_PORT: 6379
REDIS_DATABASE: 0
# DB is linked
DB_HOST: mysql
DB_NAME: user_cms
DB_PORT: 3306
DB_USER: user_cms
DB_PASS: secret
# Craft specific
APPID: app_id
DEV: false
BASEURL: http://domain.dev/
assets:
build: .
restart: 'always'
volumes:
- ./assets/src:/app/assets/src
- ./public/dist:/app/public/dist
command: /bin/bash -c 'npm i && npm start'
mysql:
image: mysql:5.6
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: user_cms
MYSQL_PASSWORD: secret
MYSQL_DATABASE: user_cms
volumes:
# Persistent data baby
- /var/lib/mysql
- ./dump:/dump
redis:
image: redis
FROM sealink/craftdocker:2.6.2791
# install plugins
COPY composer.json /app/
COPY composer-post-install /app/
COPY vendor /app/vendor
RUN composer install
# node packages
COPY package.json /app/
RUN npm install
ADD ./config /app/craft/config
ADD ./templates /app/craft/templates
ADD ./public /app/public
ADD ./assets /app/assets
# build assets
COPY gulpfile.coffee /app/
RUN npm run build
#!/bin/bash
set -e
function import_failed {
echo ""
echo "Connection probably failed due to db being created..."
echo "Try again in a second..."
exit 1
}
BACKUP_FILE = '/path/to/backup/craft_cms_db.tar.gz
echo " * Copy live db to ./dump"
mkdir -p dump
echo " * -> Grabbing ${BACKUP_FILE}"
gunzip -c ${BACKUP_FILE} > ./dump/craft_cms_db.sql
# Pipping from host into docker timed out on OS X
# ./bin/mysql-docker < dump/sealink_cms_latest.sql
echo " * Import db into mysql docker instance"
docker-compose run mysql \
sh -c 'mysql -uroot -p${MYSQL_ENV_MYSQL_ROOT_PASSWORD} -hmysql craft_cms_db < /dump/craft_cms_db.sql' \
|| import_failed
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment