Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vendor-sync): use specified directory instead of curl and zip files #141

Open
wants to merge 3 commits into
base: release/1.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/modules/createConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable global-require, import/no-dynamic-require */
const fs = require('fs-extra');
const { execSync } = require('child_process');
const path = require('path');
const glob = require('glob');
const { get, defaults } = require('lodash');
Expand Down Expand Up @@ -153,9 +154,22 @@ const createConfig = async (packageDir, hasVolumeSupport = true) => {
htaccessFile = `${htaccessFile}-subfolder`;
}

const composerWordpress = path.resolve( CWD, version[0] );
const vendorSync = `${packageDir}/wordpress`;
if ( !fs.existsSync( vendorSync ) ) {
fs.mkdirSync( vendorSync );
}
let usableVersions;
if ( fs.existsSync( composerWordpress ) ) {
execSync(`rsync -r --delete ${composerWordpress}/ ${vendorSync}/`);
usableVersions = [ 'wordpress' ];
} else {
usableVersions = validVersions;
}

await renderTemplate(`${packageDir}/lib/templates/dockerfile.ejs`, `${packageDir}/Dockerfile`, {
isWpContent: config.wpContent,
versions: validVersions,
versions: usableVersions,
vip: config.muPlugins ? config.muPlugins.vip : false,
phpVersion: config.phpVersion || 7.4,
phpMemoryLimit: config.phpMemoryLimit || '128M',
Expand All @@ -166,7 +180,7 @@ const createConfig = async (packageDir, hasVolumeSupport = true) => {
const wpCypressConfig = {
...config,
version,
validVersions,
validVersions: usableVersions,
volumes,
activePlugins,
activeTheme,
Expand Down
11 changes: 8 additions & 3 deletions lib/templates/dockerfile.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM php:<%= phpVersion %>-apache

RUN apt-get update && apt-get install -y wget libpng-dev libjpeg-dev gnupg default-mysql-client nano less unzip && rm -rf /var/lib/apt/lists/* \
RUN apt-get update && apt-get install -y wget rsync libpng-dev libjpeg-dev gnupg default-mysql-client nano less unzip && rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd \
&& docker-php-ext-install gd mysqli

Expand All @@ -22,15 +22,20 @@ RUN curl -sS https://getcomposer.org/installer --output composer-setup.php \
&& php composer-setup.php --version=1.10.16 \
&& mv composer.phar /bin/composer

<% versions.forEach((version) => { %>
<% versions.forEach((version) => {
if ( version.match(/(\d+.?)+/) ) {
%>
RUN curl https://wordpress.org/wordpress-<%= version %>.tar.gz > wordpress-<%= version %>.tar.gz && \
mkdir -p <%= workingDir %>/<%= version %> && \
tar -xzf wordpress-<%= version %>.tar.gz -C <%= workingDir %>/<%= version %> && \
mv <%= workingDir %>/<%= version %>/wordpress/* <%= workingDir %>/<%= version %> && \
rm -rf <%= workingDir %>/<%= version %>/wordpress && \
chown -R www-data:www-data <%= workingDir %>/<%= version %><% if (isWpContent) { %> && \<% } else { %>;<% } %>
<% if (isWpContent) { %>rm -rf <%= workingDir %>/<%= version %>/wp-content;<% } %>
<% }); %>
<% } else { %>
ADD <%= version %> /var/www/wordpress
RUN chown -R www-data:www-data /var/www/wordpress
<% } }); %>

<% if (vip) { %>
RUN curl https://github.com/Automattic/vip-go-mu-plugins-built/archive/master.zip -L -o /usr/src/vip-mu-plugins.zip && \
Expand Down