visiblevc / wordpress-starter

A slightly less shitty wordpress development workflow
688 stars 167 forks source link

Problem with WordPress viewing my theme after I rebuild #87

Closed josephkerkhof closed 7 years ago

josephkerkhof commented 7 years ago

Overview

docker-compose.yml

version: '2'
services:
  wordpress:
    image: visiblevc/wordpress:latest
    ports:
      - 8080:80
    volumes:
      # database configuration
      - ./data:/data
      # plugin setup that doesn't get touched by Gulp
      - ./dist/wp-content/plugins/elegant-themes-updater:/app/wp-content/plugins/elegant-themes-updater
      - ./dist/wp-content/plugins/gravityforms:/app/wp-content/plugins/gravityforms
      # theme setup that doesn't get touched by Gulp
      - ./dist/wp-content/themes/Divi:/app/wp-content/themes/Divi
      # WordPress uploads folder
      - ./dist/wp-content/uploads:/app/wp-content/uploads
      # plugin and themes that are built by Gulp
      - ./builds/themes/uw-oshkosh-divi:/app/wp-content/themes/uw-oshkosh-divi
      # - ./builds/plugins/:/app/wp-content/plugins/
    environment:
      DB_NAME: wordpress
      DB_PASS: root
      PLUGINS: >-
        404-to-301,
        adminimize,
        akismet,
        [local]elegant-themes-updater,
        ewww-image-optimizer,
        font-awesome-shortcodes,
        [local]gravityforms,
        json-content-importer,
        sidekick,
        tablepress,
        wordpress-importer,
        wordpress-seo,
        wp-simple-anchors-links
      THEMES: >-
        [local]Divi,
        [local]uw-oshkosh-divi

  db:
    image: mariadb:10 # or mysql:5.7
    volumes:
      - data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      MYSQL_ROOT_PASSWORD: root
    ports:
      - 22222:80
volumes:
  data:

Project structure

/builds
  /themes
    /uw-oshkosh-divi // This is my built theme
/config
  // some config files
/data
  db.sql
/dist
  /wp-content
    /plugins
      // A few paid plugins I want in this configuration
    /themes
      // A paid parent theme for the child theme I'm developing
    /uploads
      // Syncing the uploads folder
/src
  /themes
    /uw-oshkosh-divi // This is the theme I'm developing

docker-compose up output

wordpress_1  | Starting wordpressstarter_db_1
Starting wordpressstarter_wordpress_1
Starting wordpressstarter_phpmyadmin_1
Attaching to wordpressstarter_phpmyadmin_1, wordpressstarter_db_1, wordpressstarter_wordpress_1
phpmyadmin_1  | 2017-02-24 21:15:21,812 CRIT Supervisor running as root (no user in config file)
phpmyadmin_1  | 2017-02-24 21:15:21,812 WARN Included extra file "/etc/supervisor.d/nginx.ini" during parsing
phpmyadmin_1  | 2017-02-24 21:15:21,812 WARN Included extra file "/etc/supervisor.d/php.ini" during parsing
phpmyadmin_1  | 2017-02-24 21:15:21,821 INFO RPC interface 'supervisor' initialized
phpmyadmin_1  | 2017-02-24 21:15:21,821 CRIT Server 'unix_http_server' running without any HTTP authentication checking
phpmyadmin_1  | 2017-02-24 21:15:21,821 INFO supervisord started with pid 1
wordpress_1   | ===============================================================================
wordpress_1   |                          Begin WordPress Installation
wordpress_1   | ===============================================================================
wordpress_1   | ==> Waiting for MySQL to initialize...
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] mysqld (mysqld 10.1.20-MariaDB-1~jessie) starting as process 1 ...
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Using mutexes to ref count buffer pool pages
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: The InnoDB memory heap is disabled
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Compressed tables use zlib 1.2.8
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Using Linux native AIO
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Using SSE crc32 instructions
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Initializing buffer pool, size = 256.0M
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Completed initialization of buffer pool
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Highest supported file format is Barracuda.
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: 128 rollback segment(s) are active.
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB: Waiting for purge to start
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.34-79.1 started; log sequence number 10558031
db_1          | 2017-02-24 21:15:22 139998577788672 [Note] InnoDB: Dumping buffer pool(s) not yet started
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] Plugin 'FEEDBACK' is disabled.
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] Server socket created on IP: '::'.
db_1          | 2017-02-24 21:15:22 139999356024768 [Warning] 'proxies_priv' entry '@% root@3bd8674a4599' ignored in --skip-name-resolve mode.
phpmyadmin_1  | 2017-02-24 21:15:22,824 INFO spawned: 'php-fpm' with pid 14
db_1          | 2017-02-24 21:15:22 139999356024768 [Note] mysqld: ready for connections.
db_1          | Version: '10.1.20-MariaDB-1~jessie'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
phpmyadmin_1  | 2017-02-24 21:15:22,826 INFO spawned: 'nginx' with pid 15
wordpress_1   |   ->  mysqld is alive
wordpress_1   | ==> Configuring WordPress
wordpress_1   |   -> Generating wp-config.php file... ✓
wordpress_1   | ==> Checking database
wordpress_1   |   -> Database exists. SKIPPING... 
wordpress_1   | ==> Checking for multisite
wordpress_1   |   -> Multisite not found. SKIPPING... 
wordpress_1   | ==> Checking themes
wordpress_1   |   -> (1/2) 'Divi' listed as a local volume. SKIPPING... 
wordpress_1   |   -> (2/2) 'uw-oshkosh-divi' listed as a local volume. SKIPPING... 
wordpress_1   | ==> Checking for orphaned themes
phpmyadmin_1  | 2017-02-24 21:15:23,839 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
phpmyadmin_1  | 2017-02-24 21:15:23,840 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
wordpress_1   | ==> Checking plugins
wordpress_1   |   -> (1/13) '404-to-301' found. SKIPPING... 
wordpress_1   |   -> (2/13) 'adminimize' found. SKIPPING... 
wordpress_1   |   -> (3/13) 'akismet' found. SKIPPING... 
wordpress_1   |   -> (4/13) 'elegant-themes-updater' listed as a local volume. Activating... 
wordpress_1   |   -> (5/13) 'ewww-image-optimizer' found. SKIPPING... 
wordpress_1   |   -> (6/13) 'font-awesome-shortcodes' found. SKIPPING... 
wordpress_1   |   -> (7/13) 'gravityforms' listed as a local volume. Activating... 
wordpress_1   |   -> (8/13) 'json-content-importer' found. SKIPPING... 
wordpress_1   |   -> (9/13) 'sidekick' found. SKIPPING... 
wordpress_1   |   -> (10/13) 'tablepress' found. SKIPPING... 
wordpress_1   |   -> (11/13) 'wordpress-importer' found. SKIPPING... 
wordpress_1   |   -> (12/13) 'wordpress-seo' found. SKIPPING... 
wordpress_1   |   -> (13/13) 'wp-simple-anchors-links' found. SKIPPING... 
wordpress_1   | ==> Checking for orphaned plugins
wordpress_1   | ==> Finalizing
wordpress_1   |   -> .htaccess exists. SKIPPING... 
wordpress_1   |   -> Adjusting file permissions ✓
wordpress_1   | ===============================================================================
wordpress_1   |                        WordPress Configuration Complete!
wordpress_1   | ===============================================================================
wordpress_1   | [Fri Feb 24 21:15:38.832626 2017] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/7.0.14 configured -- resuming normal operations
wordpress_1   | [Fri Feb 24 21:15:38.832671 2017] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

gulpfile.js

const gulp = require('gulp');

// Include Our Plugins
const jshint = require('gulp-jshint');
const sass = require('gulp-sass');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const copy = require('gulp-copy');
const babel = require('gulp-babel');
const imagemin = require('gulp-imagemin');
const merge = require('merge-stream');
const svgo = require('gulp-svgo');
const mkdirp = require('gulp-mkdirp');
const clean = require('gulp-clean');
const runSequence = require('run-sequence');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
// const cssnano = require('gulp-cssnano');
const gulpif = require('gulp-if');
const scsslint = require('gulp-scss-lint');
const browserSync = require('browser-sync').create();
const watch = require('gulp-watch');

// Including the path to local WP development
const localWPConfig = require('./config/local-wp-config.js');

gulp.task('serve', function(){
  // Building and piping the files before browserSync init
  runSequence('build-theme', 'bs-init');

  // Watching all files in the src
  return watch('src/**/*.*', function(){
    runSequence('build-theme', 'build-plugin', 'bs-reload');
  });
});

// Tasks for local WordPress development
gulp.task('bs-init', function(){
  browserSync.init({
      proxy: localWPConfig.proxy
  });
});

gulp.task('bs-reload', function (){
    browserSync.reload();
});

gulp.task('build', function(cb){
  runSequence('build-theme');
});

gulp.task('build-theme', function(cb) {
  runSequence('theme-clean',
    ['theme-style', 'theme-js', 'theme-images', 'theme-php'],
    ['theme-js-lint', 'theme-scss-lint'],
    cb);
});

// Tasks for WordPress theme build
gulp.task('theme-clean', function() {
    return gulp.src('builds/themes/')
        .pipe(clean());
});

// Building the CSS
gulp.task('theme-style', function () {
  return gulp.src('src/themes/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['last 2 versions']
    }))
    .pipe(cleanCSS({
          keepSpecialComments: 1
      }))
    .pipe(gulp.dest('builds/themes/'));
});

gulp.task('theme-js', function(){
  return gulp.src('src/themes/**/js/**/*.js')
      .pipe(babel({
        presets: ['es2015']
      }))
      .pipe(uglify())
      .pipe(gulp.dest('builds/themes/'));
});

gulp.task('theme-images', function(){
  return gulp.src('src/themes/**/images/**/*')
      .pipe(imagemin())
      .pipe(gulp.dest('builds/themes/'));
});

gulp.task('theme-php', function(){
  return gulp.src('src/themes/**/**/*.php')
      .pipe(gulp.dest('builds/themes/'));
});

gulp.task('theme-js-lint', function(){
  return gulp.src('src/themes/**/js/*.js')
      .pipe(jshint({
        'esversion': 6
      }))
      .pipe(jshint.reporter('default'));
});

gulp.task('theme-scss-lint', function() {
  return gulp.src('src/themes/**/style/*.scss')
    .pipe(scsslint({'config': 'config/scss-lint-config.yml'}));
});
dsifford commented 7 years ago

Hi @musicaljoeker

The issue is that you're deleting your volume in your gulp workflow. If you delete a volume after it's been created, the only way to get it back is to rebuild.

You can prevent this by making changing your theme-clean task to this:

// Tasks for WordPress theme build
gulp.task('theme-clean', function() {
    return gulp.src('builds/themes/uw-oshkosh-divi/**')
        .pipe(clean());
});

I'm not familiar with gulp-clean so I'm assuming that module just deletes whatever you give to it?

The key takeaway point is: Don't delete the uw-oshkosh-divi folder -- just the files inside it.