Skip to content

Commit d7c3d57

Browse files
Merge branch 'municipio-se:stage' into stage
2 parents 88c79d9 + f7480ab commit d7c3d57

File tree

17 files changed

+419
-404
lines changed

17 files changed

+419
-404
lines changed

.devcontainer/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ REMOTE_PATH=/var/www/prod
1313
REMOTE_SITE_PROTOCOL=https://
1414
REMOTE_SITE_DOMAIN=example.com
1515
REMOTE_PREFIX=wp_
16+
CDN_DOMAIN=
1617

1718
# Local site configuration
1819
LOCAL_SITE_SLUG=mysite

.devcontainer/Dockerfile

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
ARG imageVariant
22
FROM mcr.microsoft.com/devcontainers/php:1-${imageVariant}
33

4+
RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --yes --dearmor -o /usr/share/keyrings/yarnkey.gpg \
5+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list > /dev/null
6+
47
# Install packages including libzip-dev before PHP extensions
58
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
69
&& apt-get install -y mariadb-client libpng-dev apache2 libfreetype6-dev libjpeg-dev libwebp-dev libmagickwand-dev imagemagick libzip-dev \
@@ -42,26 +45,25 @@ RUN curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-comp
4245
&& mv wp-completion.bash /etc/bash_completion.d/wp-completion.bash \
4346
&& echo "source /etc/bash_completion.d/wp-completion.bash" >> ~/.bashrc
4447

45-
# Generate self-signed SSL certificate and add to site conf
46-
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt \
47-
-subj "/C=US/ST=State/L=City/O=Organization/OU=Unit/CN=example.com" \
48-
&& sed -i 's/SSLCertificateFile\t\/etc\/ssl\/certs\/ssl-cert-snakeoil.pem/SSLCertificateFile \/etc\/ssl\/certs\/apache-selfsigned.crt/g' /etc/apache2/sites-available/default-ssl.conf \
49-
&& sed -i 's/SSLCertificateKeyFile \/etc\/ssl\/private\/ssl-cert-snakeoil.key/SSLCertificateKeyFile \/etc\/ssl\/private\/apache-selfsigned.key/g' /etc/apache2/sites-available/default-ssl.conf
48+
# Enable Apache modules for development (removed SSL)
5049

5150
# Install github cli
52-
RUN (type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
53-
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
51+
RUN (type -p wget >/dev/null || (apt update && apt install wget -y)) \
52+
&& mkdir -p -m 755 /etc/apt/keyrings \
5453
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
55-
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
56-
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
57-
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
58-
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
59-
&& sudo apt update \
60-
&& sudo apt install gh -y
54+
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
55+
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
56+
&& mkdir -p -m 755 /etc/apt/sources.list.d \
57+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
58+
&& apt update \
59+
&& apt install gh -y
6160

6261
# Install PHP tidy extension
6362
RUN apt-get update && apt-get install -y libtidy-dev \
6463
&& docker-php-ext-install tidy
6564

66-
RUN a2enmod headers mime rewrite ssl
67-
RUN a2ensite default-ssl
65+
# Increase php upload limit
66+
RUN echo "upload_max_filesize = 256M" >> /usr/local/etc/php/conf.d/uploads.ini \
67+
&& echo "post_max_size = 256M" >> /usr/local/etc/php/conf.d/uploads.ini
68+
69+
RUN a2enmod headers mime rewrite

.devcontainer/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ This guide provides instructions for setting up and working with the Municipio D
3030
`.devcontainer/scripts/setup.sh`
3131

3232
6. **Access the local site**
33-
Open your browser and navigate to [https://localhost:8443](https://localhost:8443).
33+
Open your browser and navigate to [http://localhost:8080](http://localhost:8080).
3434

3535
### Accessing the Local Site
3636

37-
- Navigate to [https://localhost:8443](https://localhost:8443) in your browser.
38-
- Accept the self-signed certificate warning if prompted.
37+
- Navigate to [http://localhost:8080](http://localhost:8080) in your browser.
3938
- Default login credentials:
4039
- **Username:** `superadmin`
4140
- **Password:** `superadmin`
@@ -114,7 +113,7 @@ The script will:
114113
- You may be prompted for your SSH password/key passphrase
115114
- If the local site already exists, you'll be asked whether to delete it
116115
- The script requires SSH access to the remote server
117-
- After migration, access your site at `https://localhost:8443/<LOCAL_SITE_SLUG>`
116+
- After migration, access your site at `http://localhost:8080/<LOCAL_SITE_SLUG>`
118117

119118
## Documentation for setup-dev-package.sh Script
120119
The `setup-dev-package.sh` script is a utility designed to streamline the development process by providing a clean and efficient development environment. It automates the process of downloading an editable version of the selected plugin. All other plugins in the environment will be reset to their production release versions. This ensures that only the selected plugin is in a development state, avoiding unnecessary builds for untouched packages.

.devcontainer/config/wp-config/content.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/**
44
* Tell WordPress to load from local wp-content, and not vendor wp.
55
*/
6-
$localSiteDomain = 'localhost:8443';
6+
$localSiteDomain = 'localhost:8080';
77

88
define('WP_CONTENT_DIR', dirname(dirname(__FILE__)) . '/wp-content');
9-
define('WP_CONTENT_URL', 'https://' . $localSiteDomain . '/wp-content');
9+
define('WP_CONTENT_URL', 'http://' . $localSiteDomain . '/wp-content');
1010

1111
/**
1212
* Use municipio as default theme.

.devcontainer/config/wp-config/developer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
*/
1414

1515
// Local site domain (fixed for devcontainer)
16-
$localSiteDomain = 'localhost:8443';
16+
$localSiteDomain = 'localhost:8080';
1717

1818
// Activate debug mode on all environments using ?debug flag.
1919
if (isset($_GET['debug'])) {
2020
define('WP_DEBUG', true);
2121
}
2222

2323
if (!defined('WP_SITEURL')) {
24-
define('WP_SITEURL', 'https://' . $localSiteDomain . '/wp');
24+
define('WP_SITEURL', 'http://' . $localSiteDomain . '/wp');
2525
}
2626

2727
if (!defined('WP_HOME')) {
28-
define('WP_HOME', 'https://' . $localSiteDomain);
28+
define('WP_HOME', 'http://' . $localSiteDomain);
2929
}
3030

3131
if (!defined('WP_ENVIRONMENT_TYPE')) {

.devcontainer/config/wp-config/multisite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Tell WordPress to be used as network
55
*/
6-
$localSiteDomain = 'localhost:8443';
6+
$localSiteDomain = 'localhost:8080';
77

88
define('WP_ALLOW_MULTISITE', true);
99
define('MULTISITE', true);

.devcontainer/devcontainer.json

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb
33
{
4-
"name": "Municipio Deployment(PHP & MariaDB)",
5-
"dockerComposeFile": "docker-compose.yml",
6-
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7-
"service": "app",
8-
"forwardPorts": [
9-
"443:8443",
10-
8306,
11-
8080
12-
],
13-
"containerEnv": {
14-
"XDEBUG_MODE": "off"
15-
},
16-
// Use 'postCreateCommand' to run commands after the container is created.
17-
"postCreateCommand": {
18-
"setup": "chmod +x .devcontainer/scripts/postCreateCommand.sh && bash .devcontainer/scripts/postCreateCommand.sh"
19-
},
20-
"postStartCommand": "chmod +x .devcontainer/scripts/postStartCommand.sh && bash .devcontainer/scripts/postStartCommand.sh",
21-
// Features to add to the dev container. More info: https://containers.dev/features.
22-
"features": {
23-
"ghcr.io/devcontainers/features/node:1": {
24-
"version": "24"
25-
}
26-
},
27-
//"waitFor": "postCreateCommand",
28-
// Configure tool-specific properties.
29-
"customizations": {
30-
"vscode": {
31-
"extensions": [
32-
"eamodio.gitlens",
33-
"ritwickdey.liveserver",
34-
"ms-vscode.remote-server",
35-
"cjhowe7.laravel-blade",
36-
"github.vscode-github-actions"
37-
],
38-
"settings": {
39-
"remote.autoForwardPorts": false,
40-
"remote.portsAttributes": {
41-
"443:8443": {
42-
"label": "WordPress - SSL",
43-
"onAutoForward": "notify",
44-
"requireLocalPort": true,
45-
"protocol": "https"
46-
},
47-
"8306": {
48-
"label": "Database",
49-
"onAutoForward": "notify",
50-
"requireLocalPort": false
51-
},
52-
"8080": {
53-
"label": "PhpMyAdmin",
54-
"onAutoForward": "notify",
55-
"requireLocalPort": false
56-
}
57-
},
58-
"intelephense.environment.includePaths": [
59-
"/tmp/wordpress-tests-lib",
60-
"/tmp/wordpress"
61-
],
62-
"intelephense.environment.phpVersion": "8.3"
63-
}
64-
}
65-
},
66-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
67-
"remoteUser": "root"
4+
"name": "Municipio Deployment(PHP & MariaDB)",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7+
"service": "app",
8+
"forwardPorts": [
9+
"80:8080",
10+
8306,
11+
8090
12+
],
13+
"containerEnv": {
14+
"XDEBUG_MODE": "off"
15+
},
16+
// Use 'postCreateCommand' to run commands after the container is created.
17+
"postCreateCommand": {
18+
"setup": "chmod +x .devcontainer/scripts/postCreateCommand.sh && bash .devcontainer/scripts/postCreateCommand.sh"
19+
},
20+
"postStartCommand": "chmod +x .devcontainer/scripts/postStartCommand.sh && bash .devcontainer/scripts/postStartCommand.sh",
21+
// Features to add to the dev container. More info: https://containers.dev/features.
22+
"features": {
23+
"ghcr.io/devcontainers/features/node:1": {
24+
"version": "24"
25+
}
26+
},
27+
"waitFor": "postCreateCommand",
28+
// Configure tool-specific properties.
29+
"customizations": {
30+
"vscode": {
31+
"extensions": [
32+
"eamodio.gitlens",
33+
"ritwickdey.liveserver",
34+
"ms-vscode.remote-server",
35+
"cjhowe7.laravel-blade",
36+
"github.vscode-github-actions"
37+
],
38+
"settings": {
39+
"remote.autoForwardPorts": false,
40+
"remote.portsAttributes": {
41+
"80:8080": {
42+
"label": "WordPress - HTTP",
43+
"onAutoForward": "notify",
44+
"requireLocalPort": true,
45+
"protocol": "http"
46+
},
47+
"8306": {
48+
"label": "Database",
49+
"onAutoForward": "notify",
50+
"requireLocalPort": false
51+
},
52+
"8090": {
53+
"label": "PhpMyAdmin",
54+
"onAutoForward": "notify",
55+
"requireLocalPort": false
56+
}
57+
},
58+
"intelephense.environment.includePaths": [
59+
"/tmp/wordpress-tests-lib",
60+
"/tmp/wordpress"
61+
],
62+
"intelephense.environment.phpVersion": "8.3"
63+
}
64+
}
65+
}
66+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
67+
// "remoteUser": "root"
6868
}

.devcontainer/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
imageVariant: 8.3-bullseye
88

99
ports:
10-
- 8443:443
10+
- 8080:80
1111

1212
volumes:
1313
- ../..:/workspaces:cached
@@ -34,10 +34,10 @@ services:
3434
MYSQL_PASSWORD: mariadb
3535

3636
phpmyadmin:
37-
image: phpmyadmin/phpmyadmin
37+
image: phpmyadmin:latest
3838
restart: always
3939
ports:
40-
- 8080:80
40+
- 8090:80
4141
environment:
4242
PMA_HOST: db
4343
MYSQL_ROOT_PASSWORD: mariadb
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
Plugin Name: Migrate Uploads URL
5+
Description: Migrate uploads URL to CDN. For use only in development environment when the remote site is configured to use a CDN for uploads.
6+
Version: 1.0
7+
Author: Thor Brink
8+
*/
9+
10+
add_filter('upload_dir', function ($uploads) {
11+
static $remoteSiteId = null;
12+
$localSiteId = get_current_blog_id();
13+
$localSiteUrl = get_site_url($localSiteId);
14+
$uploadUrlPath = get_option('upload_url_path');
15+
$remoteCdnDomain = get_option('remote_cdn_domain');
16+
$uploadUrlPathDomain = parse_url($uploadUrlPath, PHP_URL_HOST);
17+
18+
if ($remoteSiteId === null) {
19+
$remoteSiteId = get_option('remote_site_id');
20+
}
21+
22+
if (!is_numeric($remoteSiteId)) {
23+
return $uploads;
24+
}
25+
26+
if($remoteSiteId === "1") {
27+
$uploads['url'] = str_replace('sites/' . $localSiteId . '/', '', $uploads['url']);
28+
$uploads['baseurl'] = str_replace('sites/' . $localSiteId . '/', '', $uploads['baseurl']);
29+
}
30+
31+
$uploads['subdir'] = '';
32+
$uploads['url'] = str_replace('sites/' . $localSiteId, 'sites/' . $remoteSiteId, $uploads['url']);
33+
$uploads['url'] = str_replace('wp-content/uploads', 'uploads', $uploads['url']);
34+
$uploads['baseurl'] = str_replace('sites/' . $localSiteId, 'sites/' . $remoteSiteId, $uploads['baseurl']);
35+
$uploads['baseurl'] = str_replace('wp-content/uploads', 'uploads', $uploads['baseurl']);
36+
37+
if (!empty($remoteCdnDomain)) {
38+
$uploads['url'] = str_replace($uploadUrlPathDomain . '/uploads', $remoteCdnDomain . '/uploads', $uploads['url']);
39+
$uploads['url'] = str_replace($localSiteUrl, 'https://' . $remoteCdnDomain, $uploads['url']);
40+
$uploads['baseurl'] = str_replace($uploadUrlPathDomain . '/uploads', $remoteCdnDomain . '/uploads', $uploads['url']);
41+
$uploads['baseurl'] = str_replace($localSiteUrl, 'https://' . $remoteCdnDomain, $uploads['baseurl']);
42+
}
43+
44+
// Possibly remove year/month subdirectories from the path, url and baseurl if they exist
45+
$uploads['path'] = str_replace('/' . date('Y') . '/' . date('m'), '', $uploads['path']);
46+
$uploads['url'] = str_replace('/' . date('Y') . '/' . date('m'), '', $uploads['url']);
47+
$uploads['baseurl'] = str_replace('/' . date('Y') . '/' . date('m'), '', $uploads['baseurl']);
48+
49+
return $uploads;
50+
});

.devcontainer/scripts/dev-package/clean-packages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fi
2626

2727
if [ -d wp-content/mu-plugins ]; then
2828
# Keep loader.php
29-
find wp-content/mu-plugins/ -mindepth 1 -maxdepth 1 ! -name 'loader.php' -exec rm -rf {} +
29+
find wp-content/mu-plugins/ -mindepth 1 -maxdepth 1 ! -name 'loader.php' ! -name 'migrate.php' -exec rm -rf {} +
3030
fi
3131

3232
if [ -d wp-content/themes ]; then

0 commit comments

Comments
 (0)