Skip to content

Commit

Permalink
removed taskman and introduced secrets via env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
tabroughton committed Jul 20, 2019
1 parent 682f616 commit b1e7513
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 91 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ docker-compose.*.yml

/.mysql_history
/.bash_history

.env
\#*
.\#*
mysql/
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
# Install Backdrop
## Install Backdrop

* `cp template.env .env` and edit
* `docker-compose up -d`
* `docker-compose exec php composer install`
* `docker-compose exec php ./vendor/bin/taskman backdrop:install`

## Play with drush

* `docker-compose exec php ./vendor/bin/drush --root=build status`
* `docker exec backdrop ./vendor/bin/drush --root=build status`

Backdrop should be available at: http://127.0.0.1:8080
## Access in browser

Login is `admin`

Password is `admin`

## Available Taskman commands:

To install Backdrop
* `docker-compose exec php ./vendor/bin/taskman backdrop:install`

To remove the files and database (_usually before installing_)
* `docker-compose exec php ./vendor/bin/taskman backdrop:reset`
* <http://localhost:8080>
* admin user is admin, password set in .env
13 changes: 5 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
{
"name": "backdrop-docker/backdrop",
"description": "Run Backdrop using Docker containers.",
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"backdrop/backdrop": "^1",
"backdrop/drush": "^1",
"phptaskman/drupal": "^0.1",
"drush/drush": "^8.2"
"require": {
"backdrop/backdrop": "1.13.2-rc2",
"backdrop/drush": "1.0.0",
"drush/drush": "8.3.0"
}
}
31 changes: 27 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version: '2'
version: '3'
services:
web:
image: nginx
container_name: nginxbackdrop
ports:
- "8080:80"
volumes:
Expand All @@ -15,11 +16,19 @@ services:
build:
context: docker/php
args:
TIMEZONE: Europe/Brussels
TIMEZONE: Europe/London
container_name: backdrop
volumes:
- .:/var/www
restart: always
working_dir: "/var/www"
environment:
BACKDROP_DB_HOST: "${BACKDROP_DB_HOST}"
BACKDROP_DB_PORT: "${BACKDROP_DB_PORT}"
BACKDROP_DB_NAME: "${BACKDROP_DB_NAME}"
BACKDROP_DB_USER: "${BACKDROP_DB_USER}"
BACKDROP_DB_PASSWORD: "${BACKDROP_DB_USER_PASSWORD}"
BACKDROP_ADMIN_PASS: "${BACKDROP_ADMIN_PASS}"
depends_on:
- db
- composer
Expand All @@ -29,6 +38,20 @@ services:
- .:/var/www
working_dir: "/var/www"
db:
image: percona/percona-server:5.7
image: mariadb:latest
container_name: ${BACKDROP_DB_HOST}
ports:
- ${BACKDROP_DB_PORT}:3306
volumes:
- ./mysql:/var/lib/mysql
- ./docker/mysql/custom-mysql.conf:/etc/mysql/conf.d/custom.cnf
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: "${BACKDROP_DB_NAME}"
MYSQL_ROOT_PASSWORD: "${BACKDROP_DB_ROOT_PASSWORD}"
MYSQL_USER: "${BACKDROP_DB_USER}"
MYSQL_PASSWORD: "${BACKDROP_DB_USER_PASSWORD}"

networks:
default:
external:
name: web
8 changes: 6 additions & 2 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM php:7.3-fpm
ARG TIMEZONE

RUN apt-get update && apt-get install -y mysql-client unzip curl sqlite3 git
RUN apt-get update && apt-get install -y mariadb-client unzip curl sqlite3 git

# install the PHP extensions we need and remove dependencies once its built.
RUN set -ex; \
Expand Down Expand Up @@ -43,7 +43,7 @@ RUN set -ex; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*

ADD . /
#ADD . /

# Set timezone
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone
Expand All @@ -55,3 +55,7 @@ RUN usermod -u 1000 www-data
USER www-data

WORKDIR /var/www

#ADD --chown=root:www-data entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/var/www/docker/php/entrypoint.sh"]
33 changes: 33 additions & 0 deletions docker/php/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# this entrpoint to docker container for backdrop will check for
# backdrop webserver files and if they don't exist then it will
# install via composer and copy the files to the relevant places
#
# the environment variables are created on container creation and for
# development purposes are stored in .env file - see template.env

install_backdrop(){
./vendor/bin/drush cc drush
cp -r ./vendor/backdrop/backdrop ./build
cp -r ./vendor/backdrop/drush ./.drush/commands

./vendor/bin/drush --root=build si \
[email protected] \
--db-url=mysql://$BACKDROP_DB_USER:$BACKDROP_DB_PASSWORD@$BACKDROP_DB_HOST:$BACKDROP_DB_PORT/$BACKDROP_DB_NAME

./vendor/bin/drush --root=build user-password admin --password=$BACKDROP_ADMIN_PASSWORD
}

# let's check to see if composer has already installed the files
if [ ! -f ./vendor/backdrop/backdrop/settings.php ]; then
composer install
fi

# if our the webserver files don't exist then we need to deploy them
# from the container
if [ ! -f /var/www/html/build/settings.php ]; then
install_backdrop
fi

php-fpm # -F -R
61 changes: 0 additions & 61 deletions taskman.yml.dist

This file was deleted.

8 changes: 8 additions & 0 deletions template.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BACKDROP_DB_HOST=my_backdrop_mysql_container
BACKDROP_DB_NAME=my_backdrop_db_name
BACKDROP_DB_PORT=3306
BACKDROP_DB_ROOT_PASSWORD=super_secret
BACKDROP_DB_USER=my_backdrop_db_username
BACKDROP_DB_USER_PASSWORD=another_secret
BACKDROP_PORT=80
BACKDROP_ADMIN_PASS=webadminpassword

0 comments on commit b1e7513

Please sign in to comment.